echarts 5.3.2-rc.1 → 5.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/extension/bmap.js +406 -406
- package/dist/extension/dataTool.js +394 -394
- package/i18n/langCS-obj.js +47 -47
- package/i18n/langCS.js +43 -43
- package/i18n/langDE-obj.js +47 -47
- package/i18n/langDE.js +43 -43
- package/i18n/langEN-obj.js +47 -47
- package/i18n/langEN.js +43 -43
- package/i18n/langES-obj.js +47 -47
- package/i18n/langES.js +43 -43
- package/i18n/langFI-obj.js +47 -47
- package/i18n/langFI.js +43 -43
- package/i18n/langFR-obj.js +47 -47
- package/i18n/langFR.js +43 -43
- package/i18n/langIT-obj.js +47 -47
- package/i18n/langIT.js +43 -43
- package/i18n/langJA-obj.js +47 -47
- package/i18n/langJA.js +43 -43
- package/i18n/langKO-obj.js +47 -47
- package/i18n/langKO.js +43 -43
- package/i18n/langPL-obj.js +47 -47
- package/i18n/langPL.js +43 -43
- package/i18n/langPT-br-obj.js +47 -47
- package/i18n/langPT-br.js +43 -43
- package/i18n/langRO-obj.js +47 -47
- package/i18n/langRO.js +43 -43
- package/i18n/langRU-obj.js +47 -47
- package/i18n/langRU.js +43 -43
- package/i18n/langSI-obj.js +47 -47
- package/i18n/langSI.js +43 -43
- package/i18n/langTH-obj.js +47 -47
- package/i18n/langTH.js +43 -43
- package/i18n/langZH-obj.js +47 -47
- package/i18n/langZH.js +43 -43
- package/package.json +1 -1
package/dist/extension/bmap.js
CHANGED
|
@@ -1,413 +1,413 @@
|
|
|
1
|
-
|
|
2
|
-
/*
|
|
3
|
-
* Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
-
* or more contributor license agreements. See the NOTICE file
|
|
5
|
-
* distributed with this work for additional information
|
|
6
|
-
* regarding copyright ownership. The ASF licenses this file
|
|
7
|
-
* to you under the Apache License, Version 2.0 (the
|
|
8
|
-
* "License"); you may not use this file except in compliance
|
|
9
|
-
* with the License. You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing,
|
|
14
|
-
* software distributed under the License is distributed on an
|
|
15
|
-
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
-
* KIND, either express or implied. See the License for the
|
|
17
|
-
* specific language governing permissions and limitations
|
|
18
|
-
* under the License.
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
(function (global, factory) {
|
|
22
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('echarts')) :
|
|
23
|
-
typeof define === 'function' && define.amd ? define(['exports', 'echarts'], factory) :
|
|
24
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bmap = {}, global.echarts));
|
|
25
|
-
}(this, (function (exports, echarts) { 'use strict';
|
|
26
|
-
|
|
27
|
-
function BMapCoordSys(bmap, api) {
|
|
28
|
-
this._bmap = bmap;
|
|
29
|
-
this.dimensions = ['lng', 'lat'];
|
|
30
|
-
this._mapOffset = [0, 0];
|
|
31
|
-
this._api = api;
|
|
32
|
-
this._projection = new BMap.MercatorProjection();
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
BMapCoordSys.prototype.dimensions = ['lng', 'lat'];
|
|
36
|
-
|
|
37
|
-
BMapCoordSys.prototype.setZoom = function (zoom) {
|
|
38
|
-
this._zoom = zoom;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
BMapCoordSys.prototype.setCenter = function (center) {
|
|
42
|
-
this._center = this._projection.lngLatToPoint(new BMap.Point(center[0], center[1]));
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
BMapCoordSys.prototype.setMapOffset = function (mapOffset) {
|
|
46
|
-
this._mapOffset = mapOffset;
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
BMapCoordSys.prototype.getBMap = function () {
|
|
50
|
-
return this._bmap;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
BMapCoordSys.prototype.dataToPoint = function (data) {
|
|
54
|
-
var point = new BMap.Point(data[0], data[1]); // TODO mercator projection is toooooooo slow
|
|
55
|
-
// let mercatorPoint = this._projection.lngLatToPoint(point);
|
|
56
|
-
// let width = this._api.getZr().getWidth();
|
|
57
|
-
// let height = this._api.getZr().getHeight();
|
|
58
|
-
// let divider = Math.pow(2, 18 - 10);
|
|
59
|
-
// return [
|
|
60
|
-
// Math.round((mercatorPoint.x - this._center.x) / divider + width / 2),
|
|
61
|
-
// Math.round((this._center.y - mercatorPoint.y) / divider + height / 2)
|
|
62
|
-
// ];
|
|
63
|
-
|
|
64
|
-
var px = this._bmap.pointToOverlayPixel(point);
|
|
65
|
-
|
|
66
|
-
var mapOffset = this._mapOffset;
|
|
67
|
-
return [px.x - mapOffset[0], px.y - mapOffset[1]];
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
BMapCoordSys.prototype.pointToData = function (pt) {
|
|
71
|
-
var mapOffset = this._mapOffset;
|
|
72
|
-
pt = this._bmap.overlayPixelToPoint({
|
|
73
|
-
x: pt[0] + mapOffset[0],
|
|
74
|
-
y: pt[1] + mapOffset[1]
|
|
75
|
-
});
|
|
76
|
-
return [pt.lng, pt.lat];
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
BMapCoordSys.prototype.getViewRect = function () {
|
|
80
|
-
var api = this._api;
|
|
81
|
-
return new echarts.graphic.BoundingRect(0, 0, api.getWidth(), api.getHeight());
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
BMapCoordSys.prototype.getRoamTransform = function () {
|
|
85
|
-
return echarts.matrix.create();
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
BMapCoordSys.prototype.prepareCustoms = function () {
|
|
89
|
-
var rect = this.getViewRect();
|
|
90
|
-
return {
|
|
91
|
-
coordSys: {
|
|
92
|
-
// The name exposed to user is always 'cartesian2d' but not 'grid'.
|
|
93
|
-
type: 'bmap',
|
|
94
|
-
x: rect.x,
|
|
95
|
-
y: rect.y,
|
|
96
|
-
width: rect.width,
|
|
97
|
-
height: rect.height
|
|
98
|
-
},
|
|
99
|
-
api: {
|
|
100
|
-
coord: echarts.util.bind(this.dataToPoint, this),
|
|
101
|
-
size: echarts.util.bind(dataToCoordSize, this)
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
function dataToCoordSize(dataSize, dataItem) {
|
|
107
|
-
dataItem = dataItem || [0, 0];
|
|
108
|
-
return echarts.util.map([0, 1], function (dimIdx) {
|
|
109
|
-
var val = dataItem[dimIdx];
|
|
110
|
-
var halfSize = dataSize[dimIdx] / 2;
|
|
111
|
-
var p1 = [];
|
|
112
|
-
var p2 = [];
|
|
113
|
-
p1[dimIdx] = val - halfSize;
|
|
114
|
-
p2[dimIdx] = val + halfSize;
|
|
115
|
-
p1[1 - dimIdx] = p2[1 - dimIdx] = dataItem[1 - dimIdx];
|
|
116
|
-
return Math.abs(this.dataToPoint(p1)[dimIdx] - this.dataToPoint(p2)[dimIdx]);
|
|
117
|
-
}, this);
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
var Overlay; // For deciding which dimensions to use when creating list data
|
|
121
|
-
|
|
122
|
-
BMapCoordSys.dimensions = BMapCoordSys.prototype.dimensions;
|
|
123
|
-
|
|
124
|
-
function createOverlayCtor() {
|
|
125
|
-
function Overlay(root) {
|
|
126
|
-
this._root = root;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
Overlay.prototype = new BMap.Overlay();
|
|
1
|
+
|
|
2
|
+
/*
|
|
3
|
+
* Licensed to the Apache Software Foundation (ASF) under one
|
|
4
|
+
* or more contributor license agreements. See the NOTICE file
|
|
5
|
+
* distributed with this work for additional information
|
|
6
|
+
* regarding copyright ownership. The ASF licenses this file
|
|
7
|
+
* to you under the Apache License, Version 2.0 (the
|
|
8
|
+
* "License"); you may not use this file except in compliance
|
|
9
|
+
* with the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing,
|
|
14
|
+
* software distributed under the License is distributed on an
|
|
15
|
+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
16
|
+
* KIND, either express or implied. See the License for the
|
|
17
|
+
* specific language governing permissions and limitations
|
|
18
|
+
* under the License.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
(function (global, factory) {
|
|
22
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('echarts')) :
|
|
23
|
+
typeof define === 'function' && define.amd ? define(['exports', 'echarts'], factory) :
|
|
24
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.bmap = {}, global.echarts));
|
|
25
|
+
}(this, (function (exports, echarts) { 'use strict';
|
|
26
|
+
|
|
27
|
+
function BMapCoordSys(bmap, api) {
|
|
28
|
+
this._bmap = bmap;
|
|
29
|
+
this.dimensions = ['lng', 'lat'];
|
|
30
|
+
this._mapOffset = [0, 0];
|
|
31
|
+
this._api = api;
|
|
32
|
+
this._projection = new BMap.MercatorProjection();
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
BMapCoordSys.prototype.dimensions = ['lng', 'lat'];
|
|
36
|
+
|
|
37
|
+
BMapCoordSys.prototype.setZoom = function (zoom) {
|
|
38
|
+
this._zoom = zoom;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
BMapCoordSys.prototype.setCenter = function (center) {
|
|
42
|
+
this._center = this._projection.lngLatToPoint(new BMap.Point(center[0], center[1]));
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
BMapCoordSys.prototype.setMapOffset = function (mapOffset) {
|
|
46
|
+
this._mapOffset = mapOffset;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
BMapCoordSys.prototype.getBMap = function () {
|
|
50
|
+
return this._bmap;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
BMapCoordSys.prototype.dataToPoint = function (data) {
|
|
54
|
+
var point = new BMap.Point(data[0], data[1]); // TODO mercator projection is toooooooo slow
|
|
55
|
+
// let mercatorPoint = this._projection.lngLatToPoint(point);
|
|
56
|
+
// let width = this._api.getZr().getWidth();
|
|
57
|
+
// let height = this._api.getZr().getHeight();
|
|
58
|
+
// let divider = Math.pow(2, 18 - 10);
|
|
59
|
+
// return [
|
|
60
|
+
// Math.round((mercatorPoint.x - this._center.x) / divider + width / 2),
|
|
61
|
+
// Math.round((this._center.y - mercatorPoint.y) / divider + height / 2)
|
|
62
|
+
// ];
|
|
63
|
+
|
|
64
|
+
var px = this._bmap.pointToOverlayPixel(point);
|
|
65
|
+
|
|
66
|
+
var mapOffset = this._mapOffset;
|
|
67
|
+
return [px.x - mapOffset[0], px.y - mapOffset[1]];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
BMapCoordSys.prototype.pointToData = function (pt) {
|
|
71
|
+
var mapOffset = this._mapOffset;
|
|
72
|
+
pt = this._bmap.overlayPixelToPoint({
|
|
73
|
+
x: pt[0] + mapOffset[0],
|
|
74
|
+
y: pt[1] + mapOffset[1]
|
|
75
|
+
});
|
|
76
|
+
return [pt.lng, pt.lat];
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
BMapCoordSys.prototype.getViewRect = function () {
|
|
80
|
+
var api = this._api;
|
|
81
|
+
return new echarts.graphic.BoundingRect(0, 0, api.getWidth(), api.getHeight());
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
BMapCoordSys.prototype.getRoamTransform = function () {
|
|
85
|
+
return echarts.matrix.create();
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
BMapCoordSys.prototype.prepareCustoms = function () {
|
|
89
|
+
var rect = this.getViewRect();
|
|
90
|
+
return {
|
|
91
|
+
coordSys: {
|
|
92
|
+
// The name exposed to user is always 'cartesian2d' but not 'grid'.
|
|
93
|
+
type: 'bmap',
|
|
94
|
+
x: rect.x,
|
|
95
|
+
y: rect.y,
|
|
96
|
+
width: rect.width,
|
|
97
|
+
height: rect.height
|
|
98
|
+
},
|
|
99
|
+
api: {
|
|
100
|
+
coord: echarts.util.bind(this.dataToPoint, this),
|
|
101
|
+
size: echarts.util.bind(dataToCoordSize, this)
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
function dataToCoordSize(dataSize, dataItem) {
|
|
107
|
+
dataItem = dataItem || [0, 0];
|
|
108
|
+
return echarts.util.map([0, 1], function (dimIdx) {
|
|
109
|
+
var val = dataItem[dimIdx];
|
|
110
|
+
var halfSize = dataSize[dimIdx] / 2;
|
|
111
|
+
var p1 = [];
|
|
112
|
+
var p2 = [];
|
|
113
|
+
p1[dimIdx] = val - halfSize;
|
|
114
|
+
p2[dimIdx] = val + halfSize;
|
|
115
|
+
p1[1 - dimIdx] = p2[1 - dimIdx] = dataItem[1 - dimIdx];
|
|
116
|
+
return Math.abs(this.dataToPoint(p1)[dimIdx] - this.dataToPoint(p2)[dimIdx]);
|
|
117
|
+
}, this);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
var Overlay; // For deciding which dimensions to use when creating list data
|
|
121
|
+
|
|
122
|
+
BMapCoordSys.dimensions = BMapCoordSys.prototype.dimensions;
|
|
123
|
+
|
|
124
|
+
function createOverlayCtor() {
|
|
125
|
+
function Overlay(root) {
|
|
126
|
+
this._root = root;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
Overlay.prototype = new BMap.Overlay();
|
|
130
130
|
/**
|
|
131
131
|
* 初始化
|
|
132
132
|
*
|
|
133
133
|
* @param {BMap.Map} map
|
|
134
134
|
* @override
|
|
135
|
-
*/
|
|
136
|
-
|
|
137
|
-
Overlay.prototype.initialize = function (map) {
|
|
138
|
-
map.getPanes().labelPane.appendChild(this._root);
|
|
139
|
-
return this._root;
|
|
140
|
-
};
|
|
135
|
+
*/
|
|
136
|
+
|
|
137
|
+
Overlay.prototype.initialize = function (map) {
|
|
138
|
+
map.getPanes().labelPane.appendChild(this._root);
|
|
139
|
+
return this._root;
|
|
140
|
+
};
|
|
141
141
|
/**
|
|
142
142
|
* @override
|
|
143
|
-
*/
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
Overlay.prototype.draw = function () {};
|
|
147
|
-
|
|
148
|
-
return Overlay;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
BMapCoordSys.create = function (ecModel, api) {
|
|
152
|
-
var bmapCoordSys;
|
|
153
|
-
var root = api.getDom(); // TODO Dispose
|
|
154
|
-
|
|
155
|
-
ecModel.eachComponent('bmap', function (bmapModel) {
|
|
156
|
-
var painter = api.getZr().painter;
|
|
157
|
-
var viewportRoot = painter.getViewportRoot();
|
|
158
|
-
|
|
159
|
-
if (typeof BMap === 'undefined') {
|
|
160
|
-
throw new Error('BMap api is not loaded');
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
Overlay = Overlay || createOverlayCtor();
|
|
164
|
-
|
|
165
|
-
if (bmapCoordSys) {
|
|
166
|
-
throw new Error('Only one bmap component can exist');
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
var bmap;
|
|
170
|
-
|
|
171
|
-
if (!bmapModel.__bmap) {
|
|
172
|
-
// Not support IE8
|
|
173
|
-
var bmapRoot = root.querySelector('.ec-extension-bmap');
|
|
174
|
-
|
|
175
|
-
if (bmapRoot) {
|
|
176
|
-
// Reset viewport left and top, which will be changed
|
|
177
|
-
// in moving handler in BMapView
|
|
178
|
-
viewportRoot.style.left = '0px';
|
|
179
|
-
viewportRoot.style.top = '0px';
|
|
180
|
-
root.removeChild(bmapRoot);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
bmapRoot = document.createElement('div');
|
|
184
|
-
bmapRoot.className = 'ec-extension-bmap'; // fix #13424
|
|
185
|
-
|
|
186
|
-
bmapRoot.style.cssText = 'position:absolute;width:100%;height:100%';
|
|
187
|
-
root.appendChild(bmapRoot); // initializes bmap
|
|
188
|
-
|
|
189
|
-
var mapOptions = bmapModel.get('mapOptions');
|
|
190
|
-
|
|
191
|
-
if (mapOptions) {
|
|
192
|
-
mapOptions = echarts.util.clone(mapOptions); // Not support `mapType`, use `bmap.setMapType(MapType)` instead.
|
|
193
|
-
|
|
194
|
-
delete mapOptions.mapType;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
bmap = bmapModel.__bmap = new BMap.Map(bmapRoot, mapOptions);
|
|
198
|
-
var overlay = new Overlay(viewportRoot);
|
|
199
|
-
bmap.addOverlay(overlay); // Override
|
|
200
|
-
|
|
201
|
-
painter.getViewportRootOffset = function () {
|
|
202
|
-
return {
|
|
203
|
-
offsetLeft: 0,
|
|
204
|
-
offsetTop: 0
|
|
205
|
-
};
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
bmap = bmapModel.__bmap; // Set bmap options
|
|
210
|
-
// centerAndZoom before layout and render
|
|
211
|
-
|
|
212
|
-
var center = bmapModel.get('center');
|
|
213
|
-
var zoom = bmapModel.get('zoom');
|
|
214
|
-
|
|
215
|
-
if (center && zoom) {
|
|
216
|
-
var bmapCenter = bmap.getCenter();
|
|
217
|
-
var bmapZoom = bmap.getZoom();
|
|
218
|
-
var centerOrZoomChanged = bmapModel.centerOrZoomChanged([bmapCenter.lng, bmapCenter.lat], bmapZoom);
|
|
219
|
-
|
|
220
|
-
if (centerOrZoomChanged) {
|
|
221
|
-
var pt = new BMap.Point(center[0], center[1]);
|
|
222
|
-
bmap.centerAndZoom(pt, zoom);
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
bmapCoordSys = new BMapCoordSys(bmap, api);
|
|
227
|
-
bmapCoordSys.setMapOffset(bmapModel.__mapOffset || [0, 0]);
|
|
228
|
-
bmapCoordSys.setZoom(zoom);
|
|
229
|
-
bmapCoordSys.setCenter(center);
|
|
230
|
-
bmapModel.coordinateSystem = bmapCoordSys;
|
|
231
|
-
});
|
|
232
|
-
ecModel.eachSeries(function (seriesModel) {
|
|
233
|
-
if (seriesModel.get('coordinateSystem') === 'bmap') {
|
|
234
|
-
seriesModel.coordinateSystem = bmapCoordSys;
|
|
235
|
-
}
|
|
236
|
-
});
|
|
237
|
-
};
|
|
238
|
-
|
|
239
|
-
function v2Equal(a, b) {
|
|
240
|
-
return a && b && a[0] === b[0] && a[1] === b[1];
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
echarts.extendComponentModel({
|
|
244
|
-
type: 'bmap',
|
|
245
|
-
getBMap: function () {
|
|
246
|
-
// __bmap is injected when creating BMapCoordSys
|
|
247
|
-
return this.__bmap;
|
|
248
|
-
},
|
|
249
|
-
setCenterAndZoom: function (center, zoom) {
|
|
250
|
-
this.option.center = center;
|
|
251
|
-
this.option.zoom = zoom;
|
|
252
|
-
},
|
|
253
|
-
centerOrZoomChanged: function (center, zoom) {
|
|
254
|
-
var option = this.option;
|
|
255
|
-
return !(v2Equal(center, option.center) && zoom === option.zoom);
|
|
256
|
-
},
|
|
257
|
-
defaultOption: {
|
|
258
|
-
center: [104.114129, 37.550339],
|
|
259
|
-
zoom: 5,
|
|
260
|
-
// 2.0 http://lbsyun.baidu.com/custom/index.htm
|
|
261
|
-
mapStyle: {},
|
|
262
|
-
// 3.0 http://lbsyun.baidu.com/index.php?title=open/custom
|
|
263
|
-
mapStyleV2: {},
|
|
264
|
-
// See https://lbsyun.baidu.com/cms/jsapi/reference/jsapi_reference.html#a0b1
|
|
265
|
-
mapOptions: {},
|
|
266
|
-
roam: false
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
|
|
270
|
-
function isEmptyObject(obj) {
|
|
271
|
-
for (var key in obj) {
|
|
272
|
-
if (obj.hasOwnProperty(key)) {
|
|
273
|
-
return false;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
return true;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
echarts.extendComponentView({
|
|
281
|
-
type: 'bmap',
|
|
282
|
-
render: function (bMapModel, ecModel, api) {
|
|
283
|
-
var rendering = true;
|
|
284
|
-
var bmap = bMapModel.getBMap();
|
|
285
|
-
var viewportRoot = api.getZr().painter.getViewportRoot();
|
|
286
|
-
var coordSys = bMapModel.coordinateSystem;
|
|
287
|
-
|
|
288
|
-
var moveHandler = function (type, target) {
|
|
289
|
-
if (rendering) {
|
|
290
|
-
return;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
var offsetEl = viewportRoot.parentNode.parentNode.parentNode;
|
|
294
|
-
var mapOffset = [-parseInt(offsetEl.style.left, 10) || 0, -parseInt(offsetEl.style.top, 10) || 0]; // only update style when map offset changed
|
|
295
|
-
|
|
296
|
-
var viewportRootStyle = viewportRoot.style;
|
|
297
|
-
var offsetLeft = mapOffset[0] + 'px';
|
|
298
|
-
var offsetTop = mapOffset[1] + 'px';
|
|
299
|
-
|
|
300
|
-
if (viewportRootStyle.left !== offsetLeft) {
|
|
301
|
-
viewportRootStyle.left = offsetLeft;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
if (viewportRootStyle.top !== offsetTop) {
|
|
305
|
-
viewportRootStyle.top = offsetTop;
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
coordSys.setMapOffset(mapOffset);
|
|
309
|
-
bMapModel.__mapOffset = mapOffset;
|
|
310
|
-
api.dispatchAction({
|
|
311
|
-
type: 'bmapRoam',
|
|
312
|
-
animation: {
|
|
313
|
-
duration: 0
|
|
314
|
-
}
|
|
315
|
-
});
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
function zoomEndHandler() {
|
|
319
|
-
if (rendering) {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
api.dispatchAction({
|
|
324
|
-
type: 'bmapRoam',
|
|
325
|
-
animation: {
|
|
326
|
-
duration: 0
|
|
327
|
-
}
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
bmap.removeEventListener('moving', this._oldMoveHandler);
|
|
332
|
-
bmap.removeEventListener('moveend', this._oldMoveHandler);
|
|
333
|
-
bmap.removeEventListener('zoomend', this._oldZoomEndHandler);
|
|
334
|
-
bmap.addEventListener('moving', moveHandler);
|
|
335
|
-
bmap.addEventListener('moveend', moveHandler);
|
|
336
|
-
bmap.addEventListener('zoomend', zoomEndHandler);
|
|
337
|
-
this._oldMoveHandler = moveHandler;
|
|
338
|
-
this._oldZoomEndHandler = zoomEndHandler;
|
|
339
|
-
var roam = bMapModel.get('roam');
|
|
340
|
-
|
|
341
|
-
if (roam && roam !== 'scale') {
|
|
342
|
-
bmap.enableDragging();
|
|
343
|
-
} else {
|
|
344
|
-
bmap.disableDragging();
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
if (roam && roam !== 'move') {
|
|
348
|
-
bmap.enableScrollWheelZoom();
|
|
349
|
-
bmap.enableDoubleClickZoom();
|
|
350
|
-
bmap.enablePinchToZoom();
|
|
351
|
-
} else {
|
|
352
|
-
bmap.disableScrollWheelZoom();
|
|
353
|
-
bmap.disableDoubleClickZoom();
|
|
354
|
-
bmap.disablePinchToZoom();
|
|
355
|
-
}
|
|
356
|
-
/* map 2.0 */
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
var originalStyle = bMapModel.__mapStyle;
|
|
360
|
-
var newMapStyle = bMapModel.get('mapStyle') || {}; // FIXME, Not use JSON methods
|
|
361
|
-
|
|
362
|
-
var mapStyleStr = JSON.stringify(newMapStyle);
|
|
363
|
-
|
|
364
|
-
if (JSON.stringify(originalStyle) !== mapStyleStr) {
|
|
365
|
-
// FIXME May have blank tile when dragging if setMapStyle
|
|
366
|
-
if (!isEmptyObject(newMapStyle)) {
|
|
367
|
-
bmap.setMapStyle(echarts.util.clone(newMapStyle));
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
bMapModel.__mapStyle = JSON.parse(mapStyleStr);
|
|
371
|
-
}
|
|
372
|
-
/* map 3.0 */
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
var originalStyle2 = bMapModel.__mapStyle2;
|
|
376
|
-
var newMapStyle2 = bMapModel.get('mapStyleV2') || {}; // FIXME, Not use JSON methods
|
|
377
|
-
|
|
378
|
-
var mapStyleStr2 = JSON.stringify(newMapStyle2);
|
|
379
|
-
|
|
380
|
-
if (JSON.stringify(originalStyle2) !== mapStyleStr2) {
|
|
381
|
-
// FIXME May have blank tile when dragging if setMapStyle
|
|
382
|
-
if (!isEmptyObject(newMapStyle2)) {
|
|
383
|
-
bmap.setMapStyleV2(echarts.util.clone(newMapStyle2));
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
bMapModel.__mapStyle2 = JSON.parse(mapStyleStr2);
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
rendering = false;
|
|
390
|
-
}
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
echarts.registerCoordinateSystem('bmap', BMapCoordSys); // Action
|
|
394
|
-
|
|
395
|
-
echarts.registerAction({
|
|
396
|
-
type: 'bmapRoam',
|
|
397
|
-
event: 'bmapRoam',
|
|
398
|
-
update: 'updateLayout'
|
|
399
|
-
}, function (payload, ecModel) {
|
|
400
|
-
ecModel.eachComponent('bmap', function (bMapModel) {
|
|
401
|
-
var bmap = bMapModel.getBMap();
|
|
402
|
-
var center = bmap.getCenter();
|
|
403
|
-
bMapModel.setCenterAndZoom([center.lng, center.lat], bmap.getZoom());
|
|
404
|
-
});
|
|
405
|
-
});
|
|
406
|
-
var version = '1.0.0';
|
|
407
|
-
|
|
408
|
-
exports.version = version;
|
|
409
|
-
|
|
410
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
411
|
-
|
|
412
|
-
})));
|
|
413
|
-
//# sourceMappingURL=bmap.js.map
|
|
143
|
+
*/
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
Overlay.prototype.draw = function () {};
|
|
147
|
+
|
|
148
|
+
return Overlay;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
BMapCoordSys.create = function (ecModel, api) {
|
|
152
|
+
var bmapCoordSys;
|
|
153
|
+
var root = api.getDom(); // TODO Dispose
|
|
154
|
+
|
|
155
|
+
ecModel.eachComponent('bmap', function (bmapModel) {
|
|
156
|
+
var painter = api.getZr().painter;
|
|
157
|
+
var viewportRoot = painter.getViewportRoot();
|
|
158
|
+
|
|
159
|
+
if (typeof BMap === 'undefined') {
|
|
160
|
+
throw new Error('BMap api is not loaded');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
Overlay = Overlay || createOverlayCtor();
|
|
164
|
+
|
|
165
|
+
if (bmapCoordSys) {
|
|
166
|
+
throw new Error('Only one bmap component can exist');
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
var bmap;
|
|
170
|
+
|
|
171
|
+
if (!bmapModel.__bmap) {
|
|
172
|
+
// Not support IE8
|
|
173
|
+
var bmapRoot = root.querySelector('.ec-extension-bmap');
|
|
174
|
+
|
|
175
|
+
if (bmapRoot) {
|
|
176
|
+
// Reset viewport left and top, which will be changed
|
|
177
|
+
// in moving handler in BMapView
|
|
178
|
+
viewportRoot.style.left = '0px';
|
|
179
|
+
viewportRoot.style.top = '0px';
|
|
180
|
+
root.removeChild(bmapRoot);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
bmapRoot = document.createElement('div');
|
|
184
|
+
bmapRoot.className = 'ec-extension-bmap'; // fix #13424
|
|
185
|
+
|
|
186
|
+
bmapRoot.style.cssText = 'position:absolute;width:100%;height:100%';
|
|
187
|
+
root.appendChild(bmapRoot); // initializes bmap
|
|
188
|
+
|
|
189
|
+
var mapOptions = bmapModel.get('mapOptions');
|
|
190
|
+
|
|
191
|
+
if (mapOptions) {
|
|
192
|
+
mapOptions = echarts.util.clone(mapOptions); // Not support `mapType`, use `bmap.setMapType(MapType)` instead.
|
|
193
|
+
|
|
194
|
+
delete mapOptions.mapType;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
bmap = bmapModel.__bmap = new BMap.Map(bmapRoot, mapOptions);
|
|
198
|
+
var overlay = new Overlay(viewportRoot);
|
|
199
|
+
bmap.addOverlay(overlay); // Override
|
|
200
|
+
|
|
201
|
+
painter.getViewportRootOffset = function () {
|
|
202
|
+
return {
|
|
203
|
+
offsetLeft: 0,
|
|
204
|
+
offsetTop: 0
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
bmap = bmapModel.__bmap; // Set bmap options
|
|
210
|
+
// centerAndZoom before layout and render
|
|
211
|
+
|
|
212
|
+
var center = bmapModel.get('center');
|
|
213
|
+
var zoom = bmapModel.get('zoom');
|
|
214
|
+
|
|
215
|
+
if (center && zoom) {
|
|
216
|
+
var bmapCenter = bmap.getCenter();
|
|
217
|
+
var bmapZoom = bmap.getZoom();
|
|
218
|
+
var centerOrZoomChanged = bmapModel.centerOrZoomChanged([bmapCenter.lng, bmapCenter.lat], bmapZoom);
|
|
219
|
+
|
|
220
|
+
if (centerOrZoomChanged) {
|
|
221
|
+
var pt = new BMap.Point(center[0], center[1]);
|
|
222
|
+
bmap.centerAndZoom(pt, zoom);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
bmapCoordSys = new BMapCoordSys(bmap, api);
|
|
227
|
+
bmapCoordSys.setMapOffset(bmapModel.__mapOffset || [0, 0]);
|
|
228
|
+
bmapCoordSys.setZoom(zoom);
|
|
229
|
+
bmapCoordSys.setCenter(center);
|
|
230
|
+
bmapModel.coordinateSystem = bmapCoordSys;
|
|
231
|
+
});
|
|
232
|
+
ecModel.eachSeries(function (seriesModel) {
|
|
233
|
+
if (seriesModel.get('coordinateSystem') === 'bmap') {
|
|
234
|
+
seriesModel.coordinateSystem = bmapCoordSys;
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
|
|
239
|
+
function v2Equal(a, b) {
|
|
240
|
+
return a && b && a[0] === b[0] && a[1] === b[1];
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
echarts.extendComponentModel({
|
|
244
|
+
type: 'bmap',
|
|
245
|
+
getBMap: function () {
|
|
246
|
+
// __bmap is injected when creating BMapCoordSys
|
|
247
|
+
return this.__bmap;
|
|
248
|
+
},
|
|
249
|
+
setCenterAndZoom: function (center, zoom) {
|
|
250
|
+
this.option.center = center;
|
|
251
|
+
this.option.zoom = zoom;
|
|
252
|
+
},
|
|
253
|
+
centerOrZoomChanged: function (center, zoom) {
|
|
254
|
+
var option = this.option;
|
|
255
|
+
return !(v2Equal(center, option.center) && zoom === option.zoom);
|
|
256
|
+
},
|
|
257
|
+
defaultOption: {
|
|
258
|
+
center: [104.114129, 37.550339],
|
|
259
|
+
zoom: 5,
|
|
260
|
+
// 2.0 http://lbsyun.baidu.com/custom/index.htm
|
|
261
|
+
mapStyle: {},
|
|
262
|
+
// 3.0 http://lbsyun.baidu.com/index.php?title=open/custom
|
|
263
|
+
mapStyleV2: {},
|
|
264
|
+
// See https://lbsyun.baidu.com/cms/jsapi/reference/jsapi_reference.html#a0b1
|
|
265
|
+
mapOptions: {},
|
|
266
|
+
roam: false
|
|
267
|
+
}
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
function isEmptyObject(obj) {
|
|
271
|
+
for (var key in obj) {
|
|
272
|
+
if (obj.hasOwnProperty(key)) {
|
|
273
|
+
return false;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return true;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
echarts.extendComponentView({
|
|
281
|
+
type: 'bmap',
|
|
282
|
+
render: function (bMapModel, ecModel, api) {
|
|
283
|
+
var rendering = true;
|
|
284
|
+
var bmap = bMapModel.getBMap();
|
|
285
|
+
var viewportRoot = api.getZr().painter.getViewportRoot();
|
|
286
|
+
var coordSys = bMapModel.coordinateSystem;
|
|
287
|
+
|
|
288
|
+
var moveHandler = function (type, target) {
|
|
289
|
+
if (rendering) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
var offsetEl = viewportRoot.parentNode.parentNode.parentNode;
|
|
294
|
+
var mapOffset = [-parseInt(offsetEl.style.left, 10) || 0, -parseInt(offsetEl.style.top, 10) || 0]; // only update style when map offset changed
|
|
295
|
+
|
|
296
|
+
var viewportRootStyle = viewportRoot.style;
|
|
297
|
+
var offsetLeft = mapOffset[0] + 'px';
|
|
298
|
+
var offsetTop = mapOffset[1] + 'px';
|
|
299
|
+
|
|
300
|
+
if (viewportRootStyle.left !== offsetLeft) {
|
|
301
|
+
viewportRootStyle.left = offsetLeft;
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (viewportRootStyle.top !== offsetTop) {
|
|
305
|
+
viewportRootStyle.top = offsetTop;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
coordSys.setMapOffset(mapOffset);
|
|
309
|
+
bMapModel.__mapOffset = mapOffset;
|
|
310
|
+
api.dispatchAction({
|
|
311
|
+
type: 'bmapRoam',
|
|
312
|
+
animation: {
|
|
313
|
+
duration: 0
|
|
314
|
+
}
|
|
315
|
+
});
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
function zoomEndHandler() {
|
|
319
|
+
if (rendering) {
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
api.dispatchAction({
|
|
324
|
+
type: 'bmapRoam',
|
|
325
|
+
animation: {
|
|
326
|
+
duration: 0
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
bmap.removeEventListener('moving', this._oldMoveHandler);
|
|
332
|
+
bmap.removeEventListener('moveend', this._oldMoveHandler);
|
|
333
|
+
bmap.removeEventListener('zoomend', this._oldZoomEndHandler);
|
|
334
|
+
bmap.addEventListener('moving', moveHandler);
|
|
335
|
+
bmap.addEventListener('moveend', moveHandler);
|
|
336
|
+
bmap.addEventListener('zoomend', zoomEndHandler);
|
|
337
|
+
this._oldMoveHandler = moveHandler;
|
|
338
|
+
this._oldZoomEndHandler = zoomEndHandler;
|
|
339
|
+
var roam = bMapModel.get('roam');
|
|
340
|
+
|
|
341
|
+
if (roam && roam !== 'scale') {
|
|
342
|
+
bmap.enableDragging();
|
|
343
|
+
} else {
|
|
344
|
+
bmap.disableDragging();
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (roam && roam !== 'move') {
|
|
348
|
+
bmap.enableScrollWheelZoom();
|
|
349
|
+
bmap.enableDoubleClickZoom();
|
|
350
|
+
bmap.enablePinchToZoom();
|
|
351
|
+
} else {
|
|
352
|
+
bmap.disableScrollWheelZoom();
|
|
353
|
+
bmap.disableDoubleClickZoom();
|
|
354
|
+
bmap.disablePinchToZoom();
|
|
355
|
+
}
|
|
356
|
+
/* map 2.0 */
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
var originalStyle = bMapModel.__mapStyle;
|
|
360
|
+
var newMapStyle = bMapModel.get('mapStyle') || {}; // FIXME, Not use JSON methods
|
|
361
|
+
|
|
362
|
+
var mapStyleStr = JSON.stringify(newMapStyle);
|
|
363
|
+
|
|
364
|
+
if (JSON.stringify(originalStyle) !== mapStyleStr) {
|
|
365
|
+
// FIXME May have blank tile when dragging if setMapStyle
|
|
366
|
+
if (!isEmptyObject(newMapStyle)) {
|
|
367
|
+
bmap.setMapStyle(echarts.util.clone(newMapStyle));
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
bMapModel.__mapStyle = JSON.parse(mapStyleStr);
|
|
371
|
+
}
|
|
372
|
+
/* map 3.0 */
|
|
373
|
+
|
|
374
|
+
|
|
375
|
+
var originalStyle2 = bMapModel.__mapStyle2;
|
|
376
|
+
var newMapStyle2 = bMapModel.get('mapStyleV2') || {}; // FIXME, Not use JSON methods
|
|
377
|
+
|
|
378
|
+
var mapStyleStr2 = JSON.stringify(newMapStyle2);
|
|
379
|
+
|
|
380
|
+
if (JSON.stringify(originalStyle2) !== mapStyleStr2) {
|
|
381
|
+
// FIXME May have blank tile when dragging if setMapStyle
|
|
382
|
+
if (!isEmptyObject(newMapStyle2)) {
|
|
383
|
+
bmap.setMapStyleV2(echarts.util.clone(newMapStyle2));
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
bMapModel.__mapStyle2 = JSON.parse(mapStyleStr2);
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
rendering = false;
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
|
|
393
|
+
echarts.registerCoordinateSystem('bmap', BMapCoordSys); // Action
|
|
394
|
+
|
|
395
|
+
echarts.registerAction({
|
|
396
|
+
type: 'bmapRoam',
|
|
397
|
+
event: 'bmapRoam',
|
|
398
|
+
update: 'updateLayout'
|
|
399
|
+
}, function (payload, ecModel) {
|
|
400
|
+
ecModel.eachComponent('bmap', function (bMapModel) {
|
|
401
|
+
var bmap = bMapModel.getBMap();
|
|
402
|
+
var center = bmap.getCenter();
|
|
403
|
+
bMapModel.setCenterAndZoom([center.lng, center.lat], bmap.getZoom());
|
|
404
|
+
});
|
|
405
|
+
});
|
|
406
|
+
var version = '1.0.0';
|
|
407
|
+
|
|
408
|
+
exports.version = version;
|
|
409
|
+
|
|
410
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
411
|
+
|
|
412
|
+
})));
|
|
413
|
+
//# sourceMappingURL=bmap.js.map
|