@antv/l7-component 2.9.26 → 2.9.27-alpha.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.
@@ -60,7 +60,8 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
60
60
  className: ''
61
61
  }
62
62
  };
63
- }
63
+ } // 执行scene.addMarkerLayer时调用
64
+
64
65
  }, {
65
66
  key: "addTo",
66
67
  value: function addTo(scene) {
@@ -83,7 +84,8 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
83
84
 
84
85
  this.addMarkers();
85
86
  return this;
86
- }
87
+ } // 设置容器大小
88
+
87
89
  }, {
88
90
  key: "setContainerSize",
89
91
  value: function setContainerSize() {
@@ -94,12 +96,14 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
94
96
  containerHeight: (container === null || container === void 0 ? void 0 : container.scrollHeight) || 0,
95
97
  bounds: this.mapsService.getBounds()
96
98
  };
97
- }
99
+ } // 获取容器尺寸
100
+
98
101
  }, {
99
102
  key: "getContainerSize",
100
103
  value: function getContainerSize() {
101
104
  return this.containerSize;
102
- }
105
+ } // 在图层添加单个marker
106
+
103
107
  }, {
104
108
  key: "addMarker",
105
109
  value: function addMarker(marker) {
@@ -158,13 +162,15 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
158
162
  this.clusterMarkers.map(function (m) {
159
163
  m.getElement().style.opacity = '1';
160
164
  });
161
- }
165
+ } // 返回当下的markers数据,有聚合图时返回聚合的marker列表,否则返回原始maerker列表
166
+
162
167
  }, {
163
168
  key: "getMarkers",
164
169
  value: function getMarkers() {
165
170
  var cluster = this.markerLayerOption.cluster;
166
171
  return cluster ? this.clusterMarkers : this.markers;
167
- }
172
+ } // 批量添加marker到scene
173
+
168
174
  }, {
169
175
  key: "addMarkers",
170
176
  value: function addMarkers() {
@@ -173,7 +179,8 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
173
179
  this.getMarkers().forEach(function (marker) {
174
180
  marker.addTo(_this2.scene);
175
181
  });
176
- }
182
+ } // 清除图层里的marker
183
+
177
184
  }, {
178
185
  key: "clear",
179
186
  value: function clear() {
@@ -183,9 +190,6 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
183
190
  this.clusterMarkers.forEach(function (clusterMarker) {
184
191
  clusterMarker.remove();
185
192
  });
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));
189
193
  this.markers = [];
190
194
  this.points = [];
191
195
  this.clusterMarkers = [];
@@ -195,7 +199,12 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
195
199
  value: function destroy() {
196
200
  this.clear();
197
201
  this.removeAllListeners();
198
- }
202
+ this.mapsService.off('camerachange', this.update);
203
+ this.mapsService.off('viewchange', this.update);
204
+ this.mapsService.off('camerachange', this.setContainerSize.bind(this));
205
+ this.mapsService.off('viewchange', this.setContainerSize.bind(this));
206
+ } // 将marker数据保存在point中
207
+
199
208
  }, {
200
209
  key: "addPoint",
201
210
  value: function addPoint(marker, id) {
@@ -226,11 +235,11 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
226
235
  return;
227
236
  }
228
237
 
229
- var _ref = this.markerLayerOption.clusterOption,
230
- radius = _ref.radius,
231
- _ref$minZoom = _ref.minZoom,
232
- minZoom = _ref$minZoom === void 0 ? 0 : _ref$minZoom,
233
- maxZoom = _ref.maxZoom;
238
+ var _this$markerLayerOpti2 = this.markerLayerOption.clusterOption,
239
+ radius = _this$markerLayerOpti2.radius,
240
+ _this$markerLayerOpti3 = _this$markerLayerOpti2.minZoom,
241
+ minZoom = _this$markerLayerOpti3 === void 0 ? 0 : _this$markerLayerOpti3,
242
+ maxZoom = _this$markerLayerOpti2.maxZoom;
234
243
  this.clusterIndex = new Supercluster({
235
244
  radius: radius,
236
245
  minZoom: minZoom,
@@ -257,7 +266,7 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
257
266
  field = _this3$markerLayerOpt.field,
258
267
  method = _this3$markerLayerOpt.method; // 处理聚合数据
259
268
 
260
- if (feature.properties && (_feature$properties = feature.properties) !== null && _feature$properties !== void 0 && _feature$properties.cluster_id) {
269
+ if ((_feature$properties = feature.properties) !== null && _feature$properties !== void 0 && _feature$properties.cluster_id) {
261
270
  var _feature$properties2;
262
271
 
263
272
  var clusterData = _this3.getLeaves((_feature$properties2 = feature.properties) === null || _feature$properties2 === void 0 ? void 0 : _feature$properties2.cluster_id);
@@ -300,9 +309,9 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
300
309
  key: "clusterMarker",
301
310
  value: function clusterMarker(feature) {
302
311
  var clusterOption = this.markerLayerOption.clusterOption;
303
- var _ref2 = clusterOption,
304
- _ref2$element = _ref2.element,
305
- element = _ref2$element === void 0 ? this.generateElement.bind(this) : _ref2$element;
312
+ var _ref = clusterOption,
313
+ _ref$element = _ref.element,
314
+ element = _ref$element === void 0 ? this.generateElement.bind(this) : _ref$element;
306
315
  var marker = new Marker({
307
316
  element: element(feature)
308
317
  }).setLnglat({
@@ -320,10 +329,9 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
320
329
  }, {
321
330
  key: "update",
322
331
  value: function update() {
323
- if (!this.mapsService) {
324
- return;
325
- }
332
+ if (!this.mapsService) return; // 当图层中无marker时,无需更新
326
333
 
334
+ if (this.markers.length === 0) return;
327
335
  var zoom = this.mapsService.getZoom();
328
336
  var bbox = this.mapsService.getBounds();
329
337
 
@@ -339,9 +347,9 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
339
347
  var el = DOM.create('div', 'l7-marker-cluster');
340
348
  var label = DOM.create('div', '', el);
341
349
  var span = DOM.create('span', '', label);
342
- var _this$markerLayerOpti2 = this.markerLayerOption.clusterOption,
343
- field = _this$markerLayerOpti2.field,
344
- method = _this$markerLayerOpti2.method;
350
+ var _this$markerLayerOpti4 = this.markerLayerOption.clusterOption,
351
+ field = _this$markerLayerOpti4.field,
352
+ method = _this$markerLayerOpti4.method;
345
353
  feature.properties.point_count = feature.properties.point_count || 1;
346
354
  var text = field && method ? feature.properties['point_' + method] || feature.properties[field] : feature.properties.point_count;
347
355
  span.textContent = text;
@@ -136,9 +136,6 @@ var MarkerLayer = class extends import_eventemitter3.EventEmitter {
136
136
  this.clusterMarkers.forEach((clusterMarker) => {
137
137
  clusterMarker.remove();
138
138
  });
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));
142
139
  this.markers = [];
143
140
  this.points = [];
144
141
  this.clusterMarkers = [];
@@ -146,6 +143,10 @@ var MarkerLayer = class extends import_eventemitter3.EventEmitter {
146
143
  destroy() {
147
144
  this.clear();
148
145
  this.removeAllListeners();
146
+ this.mapsService.off("camerachange", this.update);
147
+ this.mapsService.off("viewchange", this.update);
148
+ this.mapsService.off("camerachange", this.setContainerSize.bind(this));
149
+ this.mapsService.off("viewchange", this.setContainerSize.bind(this));
149
150
  }
150
151
  addPoint(marker, id) {
151
152
  const { lng, lat } = marker.getLnglat();
@@ -168,7 +169,11 @@ var MarkerLayer = class extends import_eventemitter3.EventEmitter {
168
169
  if (!this.markerLayerOption.cluster) {
169
170
  return;
170
171
  }
171
- const { radius, minZoom = 0, maxZoom } = this.markerLayerOption.clusterOption;
172
+ const {
173
+ radius,
174
+ minZoom = 0,
175
+ maxZoom
176
+ } = this.markerLayerOption.clusterOption;
172
177
  this.clusterIndex = new import_supercluster.default({
173
178
  radius,
174
179
  minZoom,
@@ -186,7 +191,7 @@ var MarkerLayer = class extends import_eventemitter3.EventEmitter {
186
191
  clusterPoint.forEach((feature) => {
187
192
  var _a, _b;
188
193
  const { field, method } = this.markerLayerOption.clusterOption;
189
- if (feature.properties && ((_a = feature.properties) == null ? void 0 : _a.cluster_id)) {
194
+ if ((_a = feature.properties) == null ? void 0 : _a.cluster_id) {
190
195
  const clusterData = this.getLeaves((_b = feature.properties) == null ? void 0 : _b.cluster_id);
191
196
  feature.properties.clusterData = clusterData;
192
197
  if (field && method) {
@@ -231,9 +236,10 @@ var MarkerLayer = class extends import_eventemitter3.EventEmitter {
231
236
  return this.markers[marker_id];
232
237
  }
233
238
  update() {
234
- if (!this.mapsService) {
239
+ if (!this.mapsService)
240
+ return;
241
+ if (this.markers.length === 0)
235
242
  return;
236
- }
237
243
  const zoom = this.mapsService.getZoom();
238
244
  const bbox = this.mapsService.getBounds();
239
245
  if (!this.bbox || Math.abs(zoom - this.zoom) >= 1 || !(0, import_l7_utils.boundsContains)(this.bbox, bbox)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antv/l7-component",
3
- "version": "2.9.26",
3
+ "version": "2.9.27-alpha.2",
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",
29
- "@antv/l7-utils": "2.9.26",
28
+ "@antv/l7-core": "2.9.27-alpha.2",
29
+ "@antv/l7-utils": "2.9.27-alpha.2",
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"
38
+ "@antv/l7-test-utils": "2.9.27-alpha.2"
39
39
  },
40
- "gitHead": "4e6f44c4ae44f7e9b9bbe627fd35406b3e7a63e1",
40
+ "gitHead": "209f0b76af7ad1c7342f5ea21aa1c2179e8c460d",
41
41
  "publishConfig": {
42
42
  "access": "public"
43
43
  }