forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathearthquakeHeatMap.html
More file actions
81 lines (67 loc) · 2.77 KB
/
earthquakeHeatMap.html
File metadata and controls
81 lines (67 loc) · 2.77 KB
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
<!--********************************************************************
* Copyright© 2000 - 2018 SuperMap Software Co.Ltd. All rights reserved.
*********************************************************************-->
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title data-i18n="resources.title_l_echartsEarthquake"></title>
<script type="text/javascript" include="papaparse,jquery" src="../js/include-web.js"></script>
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>
<script type="text/javascript" src="../../dist/leaflet/include-leaflet.js"></script>
<script type="text/javascript">
var host = window.isLocal ? window.server : "http://support.supermap.com.cn:8090";
var url = host + "/iserver/services/map-china400/rest/maps/China";
var map, heatMapLayer;
map = L.map('map', {
center: [32.67, 109.06],
zoom: 5
});
L.supermap.tiledMapLayer(url).addTo(map);
addHeatMapLayer();
function addHeatMapLayer() {
heatMapLayer = L.supermap.heatMapLayer("heatMap", {
id: "heatmap",
map: map,
radius: 10,
featureWeight: "value"
});
$.get("../data/chinaEarthquake.csv", function (response) {
var dataObj = Papa.parse(response, {
skipEmptyLines: true,
header: true
});
var data = dataObj.data;
var geojson = {
"type": "FeatureCollection",
"features": []
};
for (var i = 0; i < data.length; i++) {
var item = data[i];
var date = new Date(item.date);
var year = date.getFullYear();
//2w+地震数据
if (year > 2000 && year < 2015) {
var feature = {
"type": "feature",
"geometry": {
"type": "Point",
"coordinates": []
},
"properties": {
"value": parseFloat(item.level)
}
};
feature.geometry.coordinates = [parseFloat(item.X), parseFloat(item.Y)];
geojson.features.push(feature);
}
}
heatMapLayer.addFeatures(geojson);
heatMapLayer.addTo(map);
});
}
</script>
</body>
</html>