-
Notifications
You must be signed in to change notification settings - Fork 1
/
line.html
123 lines (121 loc) · 3.57 KB
/
line.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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>echarts extension azuremaps</title>
<link
href="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.css"
rel="stylesheet"
/>
<script src="https://atlas.microsoft.com/sdk/javascript/mapcontrol/3/atlas.min.js"></script>
<!-- ECharts CDN -->
<script
type="text/javascript"
src="https://fastly.jsdelivr.net/npm/echarts@5/dist/echarts.min.js"
></script>
<script type="text/javascript" src="../dist/echarts-extension-azure-map.min.js"></script>
<style type="text/css">
* {
margin: 0;
padding: 0;
}
html,
body,
#app,
#echarts-azuremap {
width: 100%;
height: 100%;
overflow: hidden;
}
</style>
</head>
<body onload="loadMap()">
<div id="app">
<div id="echarts-azuremap"></div>
</div>
</body>
<script>
const linesDataURI =
'https://cdn.jsdelivr.net/gh/apache/echarts-examples/public/data/asset/data/lines-bus.json';
function loadMap() {
// initialize chart
fetch(linesDataURI, { method: 'GET' })
.then((response) => response.json())
.then((data) => {
// convert
const hStep = 300 / (data.length - 1);
const busLines = [].concat.apply(
[],
data.map((busLine, idx) => {
let prevPt;
let points = [];
for (let i = 0; i < busLine.length; i += 2) {
let pt = [busLine[i], busLine[i + 1]];
if (i > 0) {
pt = [prevPt[0] + pt[0], prevPt[1] + pt[1]];
}
prevPt = pt;
points.push([pt[0] / 1e4, pt[1] / 1e4]);
}
return {
coords: points,
lineStyle: {
color: echarts.color.modifyHSL('#5A94DF', Math.round(hStep * idx)),
},
};
}),
);
const option = {
azuremap: {
view: 'Auto',
language: 'en-US',
center: [116.46, 39.92],
zoom: 10,
authOptions: {
authType: 'subscriptionKey',
subscriptionKey: 'your subscriptionKey',
},
},
series: [
{
type: 'lines',
coordinateSystem: 'azuremap',
polyline: true,
data: busLines,
silent: true,
lineStyle: {
opacity: 0.2,
width: 1,
},
progressiveThreshold: 500,
progressive: 200,
},
{
type: 'lines',
coordinateSystem: 'azuremap',
polyline: true,
data: busLines,
lineStyle: {
width: 0,
},
effect: {
constantSpeed: 20,
show: true,
trailLength: 0.1,
symbolSize: 1.5,
},
zlevel: 1,
},
],
};
const chart = echarts.init(document.getElementById('echarts-azuremap'));
chart.setOption(option);
})
.catch((e) => {
console.log('error: ' + e.toString());
});
}
</script>
</html>