@antv/l7-component 2.9.22 → 2.9.25-alpha.0
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/es/marker-layer.d.ts +3 -0
- package/es/marker-layer.js +23 -0
- package/es/marker.d.ts +3 -1
- package/es/marker.js +18 -8
- package/lib/marker-layer.js +18 -0
- package/lib/marker.js +13 -8
- package/package.json +7 -4
package/es/marker-layer.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export default class MarkerLayer extends EventEmitter {
|
|
|
12
12
|
private scene;
|
|
13
13
|
private zoom;
|
|
14
14
|
private bbox;
|
|
15
|
+
private containerSize;
|
|
15
16
|
constructor(option?: Partial<IMarkerLayerOption>);
|
|
16
17
|
getDefault(): {
|
|
17
18
|
cluster: boolean;
|
|
@@ -25,6 +26,8 @@ export default class MarkerLayer extends EventEmitter {
|
|
|
25
26
|
};
|
|
26
27
|
};
|
|
27
28
|
addTo(scene: Container): this;
|
|
29
|
+
private setContainerSize;
|
|
30
|
+
private getContainerSize;
|
|
28
31
|
addMarker(marker: IMarker): void;
|
|
29
32
|
removeMarker(marker: IMarker): void;
|
|
30
33
|
/**
|
package/es/marker-layer.js
CHANGED
|
@@ -77,13 +77,34 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
|
|
|
77
77
|
this.mapsService.on('viewchange', this.update); // amap2.0 更新事件
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
+
this.mapsService.on('camerachange', this.setContainerSize.bind(this)); // amap1.x 更新事件
|
|
81
|
+
|
|
82
|
+
this.mapsService.on('viewchange', this.setContainerSize.bind(this)); // amap2.0 更新事件
|
|
83
|
+
|
|
80
84
|
this.addMarkers();
|
|
81
85
|
return this;
|
|
82
86
|
}
|
|
87
|
+
}, {
|
|
88
|
+
key: "setContainerSize",
|
|
89
|
+
value: function setContainerSize() {
|
|
90
|
+
if (!this.mapsService) return;
|
|
91
|
+
var container = this.mapsService.getContainer();
|
|
92
|
+
this.containerSize = {
|
|
93
|
+
containerWidth: (container === null || container === void 0 ? void 0 : container.scrollWidth) || 0,
|
|
94
|
+
containerHeight: (container === null || container === void 0 ? void 0 : container.scrollHeight) || 0,
|
|
95
|
+
bounds: this.mapsService.getBounds()
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
}, {
|
|
99
|
+
key: "getContainerSize",
|
|
100
|
+
value: function getContainerSize() {
|
|
101
|
+
return this.containerSize;
|
|
102
|
+
}
|
|
83
103
|
}, {
|
|
84
104
|
key: "addMarker",
|
|
85
105
|
value: function addMarker(marker) {
|
|
86
106
|
var cluster = this.markerLayerOption.cluster;
|
|
107
|
+
marker.getMarkerLayerContainerSize = this.getContainerSize.bind(this);
|
|
87
108
|
|
|
88
109
|
if (cluster) {
|
|
89
110
|
this.addPoint(marker, this.markers.length);
|
|
@@ -163,6 +184,8 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
|
|
|
163
184
|
clusterMarker.remove();
|
|
164
185
|
});
|
|
165
186
|
this.mapsService.off('camerachange', this.update);
|
|
187
|
+
this.mapsService.off('camerachange', this.setContainerSize.bind(this));
|
|
188
|
+
this.mapsService.off('viewchange', this.setContainerSize.bind(this));
|
|
166
189
|
this.markers = [];
|
|
167
190
|
this.clusterMarkers = [];
|
|
168
191
|
}
|
package/es/marker.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ILngLat, IMarkerOption, IPoint, IPopup } from '@antv/l7-core';
|
|
1
|
+
import { ILngLat, IMarkerContainerAndBounds, IMarkerOption, IPoint, IPopup } from '@antv/l7-core';
|
|
2
2
|
import { anchorType } from '@antv/l7-utils';
|
|
3
3
|
import { EventEmitter } from 'eventemitter3';
|
|
4
4
|
import { Container } from 'inversify';
|
|
@@ -11,6 +11,7 @@ export default class Marker extends EventEmitter {
|
|
|
11
11
|
private lngLat;
|
|
12
12
|
private scene;
|
|
13
13
|
private added;
|
|
14
|
+
getMarkerLayerContainerSize(): IMarkerContainerAndBounds | void;
|
|
14
15
|
constructor(option?: Partial<IMarkerOption>);
|
|
15
16
|
getDefault(): {
|
|
16
17
|
element: undefined;
|
|
@@ -37,6 +38,7 @@ export default class Marker extends EventEmitter {
|
|
|
37
38
|
setExtData(data: any): void;
|
|
38
39
|
private update;
|
|
39
40
|
private onMapClick;
|
|
41
|
+
private getCurrentContainerSize;
|
|
40
42
|
private updatePosition;
|
|
41
43
|
private init;
|
|
42
44
|
private registerMarkerEvent;
|
package/es/marker.js
CHANGED
|
@@ -47,6 +47,9 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
_createClass(Marker, [{
|
|
50
|
+
key: "getMarkerLayerContainerSize",
|
|
51
|
+
value: function getMarkerLayerContainerSize() {}
|
|
52
|
+
}, {
|
|
50
53
|
key: "getDefault",
|
|
51
54
|
value: function getDefault() {
|
|
52
55
|
return {
|
|
@@ -282,6 +285,16 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
282
285
|
this.togglePopup();
|
|
283
286
|
}
|
|
284
287
|
}
|
|
288
|
+
}, {
|
|
289
|
+
key: "getCurrentContainerSize",
|
|
290
|
+
value: function getCurrentContainerSize() {
|
|
291
|
+
var container = this.mapsService.getContainer();
|
|
292
|
+
return {
|
|
293
|
+
containerHeight: (container === null || container === void 0 ? void 0 : container.scrollHeight) || 0,
|
|
294
|
+
containerWidth: (container === null || container === void 0 ? void 0 : container.scrollWidth) || 0,
|
|
295
|
+
bounds: this.mapsService.getBounds()
|
|
296
|
+
};
|
|
297
|
+
}
|
|
285
298
|
}, {
|
|
286
299
|
key: "updatePosition",
|
|
287
300
|
value: function updatePosition() {
|
|
@@ -295,21 +308,18 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
295
308
|
var _this$lngLat = this.lngLat,
|
|
296
309
|
lng = _this$lngLat.lng,
|
|
297
310
|
lat = _this$lngLat.lat;
|
|
298
|
-
var bounds = this.mapsService.getBounds();
|
|
299
311
|
var pos = this.mapsService.lngLatToContainer([lng, lat]);
|
|
300
312
|
|
|
301
313
|
if (element) {
|
|
302
314
|
element.style.display = 'block';
|
|
303
315
|
element.style.whiteSpace = 'nowrap';
|
|
304
|
-
var container = this.mapsService.getContainer();
|
|
305
|
-
var containerWidth = 0;
|
|
306
|
-
var containerHeight = 0;
|
|
307
316
|
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
317
|
+
var _ref = this.getMarkerLayerContainerSize() || this.getCurrentContainerSize(),
|
|
318
|
+
containerHeight = _ref.containerHeight,
|
|
319
|
+
containerWidth = _ref.containerWidth,
|
|
320
|
+
bounds = _ref.bounds;
|
|
312
321
|
|
|
322
|
+
if (!bounds) return; // 当前可视区域包含跨日界线
|
|
313
323
|
|
|
314
324
|
if (Math.abs(bounds[0][0]) > 180 || Math.abs(bounds[1][0]) > 180) {
|
|
315
325
|
if (pos.x > containerWidth) {
|
package/lib/marker-layer.js
CHANGED
|
@@ -64,11 +64,27 @@ var MarkerLayer = class extends import_eventemitter3.EventEmitter {
|
|
|
64
64
|
this.mapsService.on("camerachange", this.update);
|
|
65
65
|
this.mapsService.on("viewchange", this.update);
|
|
66
66
|
}
|
|
67
|
+
this.mapsService.on("camerachange", this.setContainerSize.bind(this));
|
|
68
|
+
this.mapsService.on("viewchange", this.setContainerSize.bind(this));
|
|
67
69
|
this.addMarkers();
|
|
68
70
|
return this;
|
|
69
71
|
}
|
|
72
|
+
setContainerSize() {
|
|
73
|
+
if (!this.mapsService)
|
|
74
|
+
return;
|
|
75
|
+
const container = this.mapsService.getContainer();
|
|
76
|
+
this.containerSize = {
|
|
77
|
+
containerWidth: (container == null ? void 0 : container.scrollWidth) || 0,
|
|
78
|
+
containerHeight: (container == null ? void 0 : container.scrollHeight) || 0,
|
|
79
|
+
bounds: this.mapsService.getBounds()
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
getContainerSize() {
|
|
83
|
+
return this.containerSize;
|
|
84
|
+
}
|
|
70
85
|
addMarker(marker) {
|
|
71
86
|
const cluster = this.markerLayerOption.cluster;
|
|
87
|
+
marker.getMarkerLayerContainerSize = this.getContainerSize.bind(this);
|
|
72
88
|
if (cluster) {
|
|
73
89
|
this.addPoint(marker, this.markers.length);
|
|
74
90
|
if (this.mapsService) {
|
|
@@ -121,6 +137,8 @@ var MarkerLayer = class extends import_eventemitter3.EventEmitter {
|
|
|
121
137
|
clusterMarker.remove();
|
|
122
138
|
});
|
|
123
139
|
this.mapsService.off("camerachange", this.update);
|
|
140
|
+
this.mapsService.off("camerachange", this.setContainerSize.bind(this));
|
|
141
|
+
this.mapsService.off("viewchange", this.setContainerSize.bind(this));
|
|
124
142
|
this.markers = [];
|
|
125
143
|
this.clusterMarkers = [];
|
|
126
144
|
}
|
package/lib/marker.js
CHANGED
|
@@ -43,6 +43,8 @@ var Marker = class extends import_eventemitter3.EventEmitter {
|
|
|
43
43
|
(0, import_l7_utils.bindAll)(["update", "onMove", "onUp", "addDragHandler", "onMapClick"], this);
|
|
44
44
|
this.init();
|
|
45
45
|
}
|
|
46
|
+
getMarkerLayerContainerSize() {
|
|
47
|
+
}
|
|
46
48
|
getDefault() {
|
|
47
49
|
return {
|
|
48
50
|
element: void 0,
|
|
@@ -203,24 +205,27 @@ var Marker = class extends import_eventemitter3.EventEmitter {
|
|
|
203
205
|
this.togglePopup();
|
|
204
206
|
}
|
|
205
207
|
}
|
|
208
|
+
getCurrentContainerSize() {
|
|
209
|
+
const container = this.mapsService.getContainer();
|
|
210
|
+
return {
|
|
211
|
+
containerHeight: (container == null ? void 0 : container.scrollHeight) || 0,
|
|
212
|
+
containerWidth: (container == null ? void 0 : container.scrollWidth) || 0,
|
|
213
|
+
bounds: this.mapsService.getBounds()
|
|
214
|
+
};
|
|
215
|
+
}
|
|
206
216
|
updatePosition() {
|
|
207
217
|
if (!this.mapsService) {
|
|
208
218
|
return;
|
|
209
219
|
}
|
|
210
220
|
const { element, offsets } = this.markerOption;
|
|
211
221
|
const { lng, lat } = this.lngLat;
|
|
212
|
-
const bounds = this.mapsService.getBounds();
|
|
213
222
|
const pos = this.mapsService.lngLatToContainer([lng, lat]);
|
|
214
223
|
if (element) {
|
|
215
224
|
element.style.display = "block";
|
|
216
225
|
element.style.whiteSpace = "nowrap";
|
|
217
|
-
const
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
if (container) {
|
|
221
|
-
containerWidth = container.scrollWidth;
|
|
222
|
-
containerHeight = container.scrollHeight;
|
|
223
|
-
}
|
|
226
|
+
const { containerHeight, containerWidth, bounds } = this.getMarkerLayerContainerSize() || this.getCurrentContainerSize();
|
|
227
|
+
if (!bounds)
|
|
228
|
+
return;
|
|
224
229
|
if (Math.abs(bounds[0][0]) > 180 || Math.abs(bounds[1][0]) > 180) {
|
|
225
230
|
if (pos.x > containerWidth) {
|
|
226
231
|
const newPos = this.mapsService.lngLatToContainer([lng - 360, lat]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-component",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.25-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"author": "lzxue",
|
|
26
26
|
"license": "ISC",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@antv/l7-core": "2.9.
|
|
29
|
-
"@antv/l7-utils": "2.9.
|
|
28
|
+
"@antv/l7-core": "2.9.25-alpha.0",
|
|
29
|
+
"@antv/l7-utils": "2.9.25-alpha.0",
|
|
30
30
|
"@babel/runtime": "^7.7.7",
|
|
31
31
|
"eventemitter3": "^4.0.0",
|
|
32
32
|
"inversify": "^5.0.1",
|
|
@@ -34,7 +34,10 @@
|
|
|
34
34
|
"reflect-metadata": "^0.1.13",
|
|
35
35
|
"supercluster": "^7.0.0"
|
|
36
36
|
},
|
|
37
|
-
"
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@antv/l7-test-utils": "2.9.25-alpha.0"
|
|
39
|
+
},
|
|
40
|
+
"gitHead": "5216ad73535dbd3c4188dd9717952db3dfcb4f71",
|
|
38
41
|
"publishConfig": {
|
|
39
42
|
"access": "public"
|
|
40
43
|
}
|