-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLeafletEChartsTest6.html
140 lines (139 loc) · 5.87 KB
/
LeafletEChartsTest6.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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Leaflet ECharts Test 6 (Global Wind Visualization)</title>
<!-- Reference: https://github.com/gnijuohz/echarts-leaflet/blob/master/example/leaflet-multiple-layers.html -->
<!-- http://echarts.baidu.com/examples/editor.html?c=global-wind-visualization&gl=1 -->
<link rel="stylesheet" href="../resources/libs/leaflet/1.3.4/leaflet.css"/>
<script src="../resources/libs/leaflet/1.3.4/leaflet.js"></script>
<script src="../resources/libs/echarts/4.1.0/echarts.min.js"></script>
<script src="../resources/libs/echarts-gl/1.1.1/echarts-gl.min.js"></script>
<script src="../resources/libs/echarts-leaflet/22b55a16/echarts-leaflet.js"></script>
<script src="../resources/libs/jquery/3.3.1/jquery-3.3.1.min.js"></script>
<style>
html, body, #map {
height: 100%;
padding: 0;
margin: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var myChart = echarts.init(document.getElementById("map"));
{
$.getJSON("ECharts/Example/data-gl/asset/data/winds.json", function (windData) {
var data = [];
var maxMag = 0;
var minMag = Infinity;
for (var j = 0; j < windData.ny; j++) {
for (var i = 0; i <= windData.nx; i++) {
// Continuous data.
var p = (i % windData.nx) + j * windData.nx;
var vx = windData.data[p][0];
var vy = windData.data[p][1];
var mag = Math.sqrt(vx * vx + vy * vy);
// 数据是一个一维数组
// [ [经度, 维度,向量经度方向的值,向量维度方向的值] ]
data.push([
i / windData.nx * 360 - 180,
j / windData.ny * 180 - 90,
vx,
vy,
mag
]);
maxMag = Math.max(mag, maxMag);
minMag = Math.min(mag, minMag);
}
}
myChart.setOption({
title: {
text: "Global Wind Visualization",
left: "center",
textStyle: {
color: "#fff"
}
},
tooltip: {
trigger: "item"
},
animation: false,
leaflet: {
center: [104.114129, 37.550339],
zoom: 4,
roam: true,
layerControl: {
position: "topright"
},
tiles: [{
label: "Gaode Road",
urlTemplate: "https://webrd0{s}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=8&x={x}&y={y}&z={z}",
options: {
subdomains: "1234"
}
}, {
label: "Gaode Image",
urlTemplate: "https://webst0{s}.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}",
options: {
subdomains: "1234"
}
}, {
label: "Map World",
urlTemplate: "https://t{s}.tianditu.com/DataServer?T=vec_w&x={x}&y={y}&l={z}",
options: {
subdomains: "1234"
}
}, {
label: "Esri Satellite",
urlTemplate: "https://server.arcgisonline.com/arcgis/rest/services/world_imagery/mapserver/tile/{z}/{y}/{x}"
}, {
label: "Open Street Map",
urlTemplate: "https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png",
options: {
attribution: '© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a>, Tiles courtesy of <a href="http://hot.openstreetmap.org/" target="_blank">Humanitarian OpenStreetMap Team</a>'
}
}, {
label: "GeoQ Blue",
urlTemplate: "https://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetPurplishBlue/MapServer/tile/{z}/{y}/{x}"
}, {
label: "None",
urlTemplate: ""
}]
},
visualMap: {
left: "left",
min: minMag,
max: maxMag,
dimension: 4,
inRange: {
// color: ["green", "yellow", "red"]
color: ["#313695", "#4575b4", "#74add1", "#abd9e9", "#e0f3f8", "#ffffbf", "#fee090", "#fdae61", "#f46d43", "#d73027", "#a50026"]
},
realtime: false,
calculable: true,
textStyle: {
color: "#fff"
}
},
series: [{
type: "flowGL",
coordinateSystem: "leaflet",
data: data,
supersampling: 4,
particleType: "line",
particleDensity: 128,
particleSpeed: 1,
// gridWidth: windData.nx,
// gridHeight: windData.ny,
itemStyle: {
opacity: 0.7
}
}]
});
});
}
</script>
</body>
</html>