@antv/l7-component 2.9.26-alpha.2 → 2.9.27-alpha.1

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.
@@ -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
  /**
@@ -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,7 +184,11 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
163
184
  clusterMarker.remove();
164
185
  });
165
186
  this.mapsService.off('camerachange', this.update);
187
+ this.mapsService.off('viewchange', this.update);
188
+ this.mapsService.off('camerachange', this.setContainerSize.bind(this));
189
+ this.mapsService.off('viewchange', this.setContainerSize.bind(this));
166
190
  this.markers = [];
191
+ this.points = [];
167
192
  this.clusterMarkers = [];
168
193
  }
169
194
  }, {
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
- if (container) {
309
- containerWidth = container.scrollWidth;
310
- containerHeight = container.scrollHeight;
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) {
@@ -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,7 +137,11 @@ 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("viewchange", this.update);
141
+ this.mapsService.off("camerachange", this.setContainerSize.bind(this));
142
+ this.mapsService.off("viewchange", this.setContainerSize.bind(this));
124
143
  this.markers = [];
144
+ this.points = [];
125
145
  this.clusterMarkers = [];
126
146
  }
127
147
  destroy() {
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 container = this.mapsService.getContainer();
218
- let containerWidth = 0;
219
- let containerHeight = 0;
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.26-alpha.2",
3
+ "version": "2.9.27-alpha.1",
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.26-alpha.2",
29
- "@antv/l7-utils": "2.9.26-alpha.2",
28
+ "@antv/l7-core": "2.9.27-alpha.1",
29
+ "@antv/l7-utils": "2.9.27-alpha.1",
30
30
  "@babel/runtime": "^7.7.7",
31
31
  "eventemitter3": "^4.0.0",
32
32
  "inversify": "^5.0.1",
@@ -35,9 +35,9 @@
35
35
  "supercluster": "^7.0.0"
36
36
  },
37
37
  "devDependencies": {
38
- "@antv/l7-test-utils": "2.9.26-alpha.2"
38
+ "@antv/l7-test-utils": "2.9.27-alpha.1"
39
39
  },
40
- "gitHead": "0780d13e5c8c1bf0649bd05e188741330a48c31f",
40
+ "gitHead": "4de1a35dd04dcb651d469b77aa66ab821453005c",
41
41
  "publishConfig": {
42
42
  "access": "public"
43
43
  }