-
Notifications
You must be signed in to change notification settings - Fork 22
/
36-canvas-heatmap.html
89 lines (74 loc) · 1.72 KB
/
36-canvas-heatmap.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
overflow: hidden;
background: rgba(0, 0, 255, 0.05);
}
#canvas {
}
</style>
</head>
<body>
<canvas id="canvas"></canvas>
<script type="text/javascript" src="../../js/mapv.js"></script>
<script type="text/javascript">
var canvas = document.querySelector('#canvas');
canvas.width = document.body.offsetWidth;
canvas.height = document.body.offsetHeight;
var ctx = canvas.getContext('2d');
var data = [
{
geometry: {
type: 'Point',
coordinates: [ctx.canvas.width * Math.random(), ctx.canvas.height * Math.random()]
},
count: 30
},
{
geometry: {
type: 'Point',
coordinates: [ctx.canvas.width * Math.random(), ctx.canvas.height * Math.random()]
},
count: 30
},
{
geometry: {
type: 'Point',
coordinates: [ctx.canvas.width * Math.random(), ctx.canvas.height * Math.random()]
},
count: 30
}
];
var randomCount = 900;
while (randomCount--) {
data.push({
geometry: {
type: 'Point',
coordinates: [ctx.canvas.width * Math.random(), ctx.canvas.height * Math.random()]
},
count: Math.random() * 30 + 5
});
}
var dataSet = new mapv.DataSet(data);
var options = {
fillStyle: 'rgba(55, 50, 250, 0.3)',
shadowColor: 'rgba(55, 50, 250, 0.8)',
globalCompositeOperation: 'lighter',
shadowBlur: 10,
size: 13,
max: 30,
maxOpacity: 0.7,
draw: 'heatmap'
}
mapv.canvasDrawHeatmap.draw(ctx, dataSet, options);
</script>
</body>
</html>