-
Notifications
You must be signed in to change notification settings - Fork 0
/
heatmap.html
58 lines (54 loc) · 1.73 KB
/
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
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>热力图</title>
<link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />
<script src="https://webapi.amap.com/maps?v=2.0&key=54eee28eafdd3487fba880c4961901cd"></script>
<script src="heatmapData.js"></script>
<style>
html,
body,
#container {
margin: 0;
padding: 0;
width: 100%;
height: 100%;
}
</style>
</head>
<body>
<div id="container"></div>
<script>
var map = new AMap.Map("container", {
resizeEnable: true,
center: [113.88311, 22.55371],
zoom: 11
});
if (!isSupportCanvas()) {
alert('热力图仅对支持canvas的浏览器适用,您所使用的浏览器不能使用热力图功能,请换个浏览器试试~')
}
var heatmap;
map.plugin(["AMap.HeatMap"],
function () {
//初始化heatmap对象
heatmap = new AMap.HeatMap(map, {
radius: 35, //给定半径
opacity: [0, 0.8]
});
//设置数据集
heatmap.setDataSet({
data: heatmapData,
max: 100
});
});
//判断浏览器是否支持canvas
function isSupportCanvas() {
var elem = document.createElement('canvas');
return !!(elem.getContext && elem.getContext('2d'));
}
</script>
</body>
</html>