-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
355 lines (336 loc) · 12.2 KB
/
index.html
File metadata and controls
355 lines (336 loc) · 12.2 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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
<!DOCTYPE html>
<html style="height: 100%">
<head>
<meta charset="utf-8">
</head>
<body style="height: 100%; margin: 0">
<div id="container" style="height: 100%"></div>
<div id="bmap"></div>
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/echarts-all-3.js"></script>
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/extension/dataTool.min.js"></script>
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/china.js"></script>
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/map/js/world.js"></script>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=ZUONbpqGBsYGXNIYHicvbAbM"></script>
<script type="text/javascript" src="http://echarts.baidu.com/gallery/vendors/echarts/extension/bmap.min.js"></script>
<script type="text/javascript">
var dom = document.getElementById("container");
var myChart = echarts.init(dom);
var app = {};
option = null;
var data = [{
name: '上海',
value: 450
}, {
name: '武汉',
value: 200
}, {
name: '北京',
value: 480
}, {
name: '重庆',
value: 175
}, {
name: '山东',
value: 400
}, {
name: '江北区华新街48号',
value: 100
},{
name: 'U城天街3栋',
value: 100
},{
name: '大学城中路17号齐福来超市门口',
value: 100
}];
var geoCoordMap = {
'上海': [121.48, 31.22],
'武汉': [114.31, 30.52],
'北京': [116.425627, 39.911013],
'山东': [117.123606, 36.685528],
'重庆': [106.547391, 29.569992],
'江北区华新街48号': [106.539626,29.574152],
'U城天街3栋': [106.300632,29.614664],
'大学城中路17号齐福来超市门口': [106.316413,29.596274]
};
var cityarr = ['上海', '武汉', '北京', '重庆', '济南', '青岛', '烟台', '潍坊']
var convertData = function(data) {
var res = [];
for (var i = 0; i < data.length; i++) {
var geoCoord = geoCoordMap[data[i].name];
if (geoCoord) {
res.push({
name: data[i].name,
value: geoCoord.concat(data[i].value)
});
}
}
// console.log(res)
return res;
};
var yizhanDate = {};
//bmap
function bmapsearch(city) {
let str = city + '菜鸟驿站';
var map = new BMap.Map("bmap");
map.centerAndZoom(new BMap.Point(116.404, 39.915), 11);
var options = {
onSearchComplete: function(results) {
if (local.getStatus() == BMAP_STATUS_SUCCESS) {
// 判断状态是否正确
var s = [];
for (var i = 0; i < results.getCurrentNumPois(); i++) {
// console.log("res", results.getPoi(i))
let poi = {};
poi = {
city: results.getPoi(i).city,
address: results.getPoi(i).address,
point: results.getPoi(i).point,
province: results.getPoi(i).province,
phoneNumber: results.getPoi(i).phoneNumber
}
s.push(poi);
}
// document.getElementById("log").innerHTML = s.join("<br>");
console.log("s", s)
yizhanDate[city] = s;
return s;
}
}
};
var local = new BMap.LocalSearch(map, options);
local.search(str);
}
//object to array
function objecttoarray(obj) {
let item = [];
for (let key in obj) {
if (isNaN(obj[key]) !== true) {
item.push(obj[key])
}
}
return item;
}
function search(cityarr) {
for (let j = 0, len = cityarr.length; j < len; j++) {
let city = cityarr[j];
let str = city + '菜鸟驿站';
let options = {
onSearchComplete: function(results) {
if (local.getStatus() == BMAP_STATUS_SUCCESS) {
// 判断状态是否正确
var s = [];
// console.log("res", results.getPoi(200))
// console.log("res", results.getNumPois())
for (var i = 0; i < results.getCurrentNumPois(); i++) {
let poi = {};
poi = {
city: results.getPoi(i).city,
address: results.getPoi(i).address,
point: objecttoarray(results.getPoi(i).point),
province: results.getPoi(i).province,
phoneNumber: results.getPoi(i).phoneNumber
}
s.push(poi);
}
// document.getElementById("log").innerHTML = s.join("<br>");
// console.log("s", s)
yizhanDate[city] = s;
for (let i = 0, len = s.length; i < len; i++) {
let item = s[i];
// console.log("item", item)
let data_item = {
name: item.address,
value: 200
}
geoCoordMap[item.address] = item.point;
data.push(data_item)
}
}
}
};
let map = new BMap.Map("bmap");
let local = new BMap.LocalSearch(map, options);
local.search(str);
}
}
search(cityarr);
setTimeout(function() {
console.log("data", data);
console.log("data", data.length);
console.log("geoCoordMap", geoCoordMap);
option = {
title: {
text: '圈滴站点数据图',
subtext: 'data from quandi',
sublink: 'http://www.quandi.com',
left: 'center'
},
tooltip: {
trigger: 'item'
},
bmap: {
center: [104.114129, 37.550339],
zoom: 4,
roam: true,
mapStyle: {
styleJson: [{
'featureType': 'water',
'elementType': 'all',
'stylers': {
'color': '#d1d1d1'
}
}, {
'featureType': 'land',
'elementType': 'all',
'stylers': {
'color': '#f3f3f3'
}
}, {
'featureType': 'railway',
'elementType': 'all',
'stylers': {
'visibility': 'off'
}
}, {
'featureType': 'highway',
'elementType': 'all',
'stylers': {
'color': '#fdfdfd'
}
}, {
'featureType': 'highway',
'elementType': 'labels',
'stylers': {
'visibility': 'off'
}
}, {
'featureType': 'arterial',
'elementType': 'geometry',
'stylers': {
'color': '#fefefe'
}
}, {
'featureType': 'arterial',
'elementType': 'geometry.fill',
'stylers': {
'color': '#fefefe'
}
}, {
'featureType': 'poi',
'elementType': 'all',
'stylers': {
'visibility': 'off'
}
}, {
'featureType': 'green',
'elementType': 'all',
'stylers': {
'visibility': 'off'
}
}, {
'featureType': 'subway',
'elementType': 'all',
'stylers': {
'visibility': 'off'
}
}, {
'featureType': 'manmade',
'elementType': 'all',
'stylers': {
'color': '#d1d1d1'
}
}, {
'featureType': 'local',
'elementType': 'all',
'stylers': {
'color': '#d1d1d1'
}
}, {
'featureType': 'arterial',
'elementType': 'labels',
'stylers': {
'visibility': 'off'
}
}, {
'featureType': 'boundary',
'elementType': 'all',
'stylers': {
'color': '#fefefe'
}
}, {
'featureType': 'building',
'elementType': 'all',
'stylers': {
'color': '#d1d1d1'
}
}, {
'featureType': 'label',
'elementType': 'labels.text.fill',
'stylers': {
'color': '#999999'
}
}]
}
},
series: [{
name: '站点',
type: 'scatter',
coordinateSystem: 'bmap',
data: convertData(data),
symbolSize: function(val) {
return val[2] / 10;
},
label: {
normal: {
formatter: '{b}',
position: 'right',
show: false
},
emphasis: {
show: true
}
},
itemStyle: {
normal: {
color: '#EE0E0E'
}
}
}, {
name: 'Top 3',
type: 'effectScatter',
coordinateSystem: 'bmap',
data: convertData(data.sort(function(a, b) {
return b.value - a.value;
}).slice(0, 3)),
symbolSize: function(val) {
return val[2] / 20;
},
showEffectOn: 'render',
rippleEffect: {
brushType: 'stroke'
},
hoverAnimation: true,
label: {
normal: {
formatter: '{b}',
position: 'right',
show: true
}
},
itemStyle: {
normal: {
color: '#9B0606',
shadowBlur: 10,
shadowColor: '#333'
}
},
zlevel: 1
}]
};
if (option && typeof option === "object") {
myChart.setOption(option, true);
}
}, 1500)
</script>
</body>
</html>