-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path地图热力图.html
244 lines (240 loc) · 7.05 KB
/
地图热力图.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<script src="echarts.min.js"></script>
</head>
<style>
*{
margin:0 auto;
padding:0;
}
</style>
<body>
<!-- 为 ECharts 准备一个具备大小(宽高)的 DOM -->
<div id="main10" style="width: 1124px;height:600px;"></div>
<script src="jquery.js"></script>
<script src="bmap.js"></script>
<!-- <script src="china.js"></script> -->
<!-- <script src="dark.js"></script> -->
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=RsIgaDtmcQ63FTIE4Z0XOAHC6z085w1R"></script>
</body>
</html>
<script>
var myChart = echarts.init(document.getElementById('main10'), 'dark');
var uploadedDataURL ="diturelitu.json";
// var t_pos = {
// left: 0,
// top: 0
// }
// var last_point = [0, 0];
// var counter = 0;
myChart.showLoading();
myChart.setOption(option = {
title: {
x: 'right',
text: "上海房价可视化",
subtext: '随机抽样10000个',
textStyle: {
color: '#fff',
fontSize: 30
}
},
tooltip: {
trigger: 'item',
transitionDuration: 0,
position: function(point, params, dom, rect, size) {
var least_area = 20;
var offset_x = 30; /* 相对于point的偏移 */
var offset_y = 30;
/* last_point的least_area范围内不会产生新的t_pos */
if (Math.abs(point[0] - last_point[0]) < least_area &&
Math.abs(point[1] - last_point[1]) < least_area &&
counter >= 2) {
return t_pos;
}
if (Math.abs(point[0] - last_point[0]) >= least_area ||
Math.abs(point[1] - last_point[1]) >= least_area) {
counter = 0;
}
counter += 1;
/* 使real_x,real_y有数值 */
if (counter == 1) {
t_pos.left = point[0] + offset_x;
t_pos.top = point[1] + offset_y;
last_point = [point[0], point[1]];
}
/* 此处进行修正tooltip的位置 */
if (counter == 2) {
var real_x = $(dom).position().left;
var real_y = $(dom).position().top;
t_pos.left += point[0] - real_x + offset_x;
t_pos.top += point[1] - real_y + offset_y;
}
return t_pos;
},
formatter: function(params) {
return params.name + ' : ' + params.value[2] + '元/平方米';
}
},
animation: false,
bmap: {
center: [121.4693, 31.123070],
zoom: 11,
roam: true,
mapStyle: {
'styleJson': [{
"featureType": "water",
"elementType": "all",
"stylers": {
"color": "#021019"
}
}, {
"featureType": "highway",
"elementType": "geometry.fill",
"stylers": {
"color": "#000000"
}
}, {
"featureType": "highway",
"elementType": "geometry.stroke",
"stylers": {
"color": "#147a92"
}
}, {
"featureType": "arterial",
"elementType": "geometry.fill",
"stylers": {
"color": "#000000"
}
}, {
"featureType": "arterial",
"elementType": "geometry.stroke",
"stylers": {
"color": "#0b3d51"
}
}, {
"featureType": "local",
"elementType": "geometry",
"stylers": {
"color": "#000000"
}
}, {
"featureType": "land",
"elementType": "all",
"stylers": {
"color": "#08304b"
}
}, {
"featureType": "railway",
"elementType": "geometry.fill",
"stylers": {
"color": "#000000"
}
}, {
"featureType": "railway",
"elementType": "geometry.stroke",
"stylers": {
"color": "#08304b"
}
}, {
"featureType": "subway",
"elementType": "geometry",
"stylers": {
"lightness": -70
}
}, {
"featureType": "building",
"elementType": "geometry.fill",
"stylers": {
"color": "#000000"
}
}, {
"featureType": "all",
"elementType": "labels.text.fill",
"stylers": {
"color": "#857f7f"
}
}, {
"featureType": "all",
"elementType": "labels.text.stroke",
"stylers": {
"color": "#000000"
}
}, {
"featureType": "building",
"elementType": "geometry",
"stylers": {
"color": "#022338"
}
}, {
"featureType": "green",
"elementType": "geometry",
"stylers": {
"color": "#062032"
}
}, {
"featureType": "boundary",
"elementType": "all",
"stylers": {
"color": "#1e1c1c"
}
}, {
"featureType": "manmade",
"elementType": "all",
"stylers": {
"color": "#022338"
}
}]
}
},
visualMap: {
type: 'piecewise',
top: '5%',
splitNumber: 5,
min: 0,
max: 10,
seriesIndex: 0,
calculable: true,
inRange: {
color: ['green', '#eac736', '#d94e5d']
},
textStyle: {
color: '#fff',
formatter: 'aaaa{value}bbbb{value2}' // 范围标签显示内容。
}
},
series: [{
type: 'scatter',
coordinateSystem: 'bmap',
symbolSize: 8,
label: {
normal: {
show: false
},
emphasis: {
show: false
}
},
}]
});
// if (!app.inNode) {
// // 添加百度地图插件
// var bmap = myChart.getModel().getComponent('bmap').getBMap();
// bmap.addControl(new BMap.MapTypeControl());
// };
// if (option && typeof option === "object") {
// myChart.setOption(option, true);
// };
$.getJSON(uploadedDataURL, function(linedata) {
myChart.hideLoading();
myChart.setOption({
visualMap: {
max: linedata[1]
},
series: [{
data: linedata[0]
}]
});
});
</script>