@antv/l7-component 2.9.27-alpha.1 → 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.
- package/es/marker-layer.js +34 -27
- package/lib/marker-layer.js +13 -8
- package/package.json +5 -5
package/es/marker-layer.js
CHANGED
|
@@ -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,10 +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('viewchange', this.update);
|
|
188
|
-
this.mapsService.off('camerachange', this.setContainerSize.bind(this));
|
|
189
|
-
this.mapsService.off('viewchange', this.setContainerSize.bind(this));
|
|
190
193
|
this.markers = [];
|
|
191
194
|
this.points = [];
|
|
192
195
|
this.clusterMarkers = [];
|
|
@@ -196,7 +199,12 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
|
|
|
196
199
|
value: function destroy() {
|
|
197
200
|
this.clear();
|
|
198
201
|
this.removeAllListeners();
|
|
199
|
-
|
|
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
|
+
|
|
200
208
|
}, {
|
|
201
209
|
key: "addPoint",
|
|
202
210
|
value: function addPoint(marker, id) {
|
|
@@ -227,11 +235,11 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
|
|
|
227
235
|
return;
|
|
228
236
|
}
|
|
229
237
|
|
|
230
|
-
var
|
|
231
|
-
radius =
|
|
232
|
-
|
|
233
|
-
minZoom =
|
|
234
|
-
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;
|
|
235
243
|
this.clusterIndex = new Supercluster({
|
|
236
244
|
radius: radius,
|
|
237
245
|
minZoom: minZoom,
|
|
@@ -258,7 +266,7 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
|
|
|
258
266
|
field = _this3$markerLayerOpt.field,
|
|
259
267
|
method = _this3$markerLayerOpt.method; // 处理聚合数据
|
|
260
268
|
|
|
261
|
-
if (
|
|
269
|
+
if ((_feature$properties = feature.properties) !== null && _feature$properties !== void 0 && _feature$properties.cluster_id) {
|
|
262
270
|
var _feature$properties2;
|
|
263
271
|
|
|
264
272
|
var clusterData = _this3.getLeaves((_feature$properties2 = feature.properties) === null || _feature$properties2 === void 0 ? void 0 : _feature$properties2.cluster_id);
|
|
@@ -301,9 +309,9 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
|
|
|
301
309
|
key: "clusterMarker",
|
|
302
310
|
value: function clusterMarker(feature) {
|
|
303
311
|
var clusterOption = this.markerLayerOption.clusterOption;
|
|
304
|
-
var
|
|
305
|
-
|
|
306
|
-
element =
|
|
312
|
+
var _ref = clusterOption,
|
|
313
|
+
_ref$element = _ref.element,
|
|
314
|
+
element = _ref$element === void 0 ? this.generateElement.bind(this) : _ref$element;
|
|
307
315
|
var marker = new Marker({
|
|
308
316
|
element: element(feature)
|
|
309
317
|
}).setLnglat({
|
|
@@ -321,10 +329,9 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
|
|
|
321
329
|
}, {
|
|
322
330
|
key: "update",
|
|
323
331
|
value: function update() {
|
|
324
|
-
if (!this.mapsService)
|
|
325
|
-
return;
|
|
326
|
-
}
|
|
332
|
+
if (!this.mapsService) return; // 当图层中无marker时,无需更新
|
|
327
333
|
|
|
334
|
+
if (this.markers.length === 0) return;
|
|
328
335
|
var zoom = this.mapsService.getZoom();
|
|
329
336
|
var bbox = this.mapsService.getBounds();
|
|
330
337
|
|
|
@@ -340,9 +347,9 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
|
|
|
340
347
|
var el = DOM.create('div', 'l7-marker-cluster');
|
|
341
348
|
var label = DOM.create('div', '', el);
|
|
342
349
|
var span = DOM.create('span', '', label);
|
|
343
|
-
var _this$
|
|
344
|
-
field = _this$
|
|
345
|
-
method = _this$
|
|
350
|
+
var _this$markerLayerOpti4 = this.markerLayerOption.clusterOption,
|
|
351
|
+
field = _this$markerLayerOpti4.field,
|
|
352
|
+
method = _this$markerLayerOpti4.method;
|
|
346
353
|
feature.properties.point_count = feature.properties.point_count || 1;
|
|
347
354
|
var text = field && method ? feature.properties['point_' + method] || feature.properties[field] : feature.properties.point_count;
|
|
348
355
|
span.textContent = text;
|
package/lib/marker-layer.js
CHANGED
|
@@ -136,10 +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("viewchange", this.update);
|
|
141
|
-
this.mapsService.off("camerachange", this.setContainerSize.bind(this));
|
|
142
|
-
this.mapsService.off("viewchange", this.setContainerSize.bind(this));
|
|
143
139
|
this.markers = [];
|
|
144
140
|
this.points = [];
|
|
145
141
|
this.clusterMarkers = [];
|
|
@@ -147,6 +143,10 @@ var MarkerLayer = class extends import_eventemitter3.EventEmitter {
|
|
|
147
143
|
destroy() {
|
|
148
144
|
this.clear();
|
|
149
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));
|
|
150
150
|
}
|
|
151
151
|
addPoint(marker, id) {
|
|
152
152
|
const { lng, lat } = marker.getLnglat();
|
|
@@ -169,7 +169,11 @@ var MarkerLayer = class extends import_eventemitter3.EventEmitter {
|
|
|
169
169
|
if (!this.markerLayerOption.cluster) {
|
|
170
170
|
return;
|
|
171
171
|
}
|
|
172
|
-
const {
|
|
172
|
+
const {
|
|
173
|
+
radius,
|
|
174
|
+
minZoom = 0,
|
|
175
|
+
maxZoom
|
|
176
|
+
} = this.markerLayerOption.clusterOption;
|
|
173
177
|
this.clusterIndex = new import_supercluster.default({
|
|
174
178
|
radius,
|
|
175
179
|
minZoom,
|
|
@@ -187,7 +191,7 @@ var MarkerLayer = class extends import_eventemitter3.EventEmitter {
|
|
|
187
191
|
clusterPoint.forEach((feature) => {
|
|
188
192
|
var _a, _b;
|
|
189
193
|
const { field, method } = this.markerLayerOption.clusterOption;
|
|
190
|
-
if (
|
|
194
|
+
if ((_a = feature.properties) == null ? void 0 : _a.cluster_id) {
|
|
191
195
|
const clusterData = this.getLeaves((_b = feature.properties) == null ? void 0 : _b.cluster_id);
|
|
192
196
|
feature.properties.clusterData = clusterData;
|
|
193
197
|
if (field && method) {
|
|
@@ -232,9 +236,10 @@ var MarkerLayer = class extends import_eventemitter3.EventEmitter {
|
|
|
232
236
|
return this.markers[marker_id];
|
|
233
237
|
}
|
|
234
238
|
update() {
|
|
235
|
-
if (!this.mapsService)
|
|
239
|
+
if (!this.mapsService)
|
|
240
|
+
return;
|
|
241
|
+
if (this.markers.length === 0)
|
|
236
242
|
return;
|
|
237
|
-
}
|
|
238
243
|
const zoom = this.mapsService.getZoom();
|
|
239
244
|
const bbox = this.mapsService.getBounds();
|
|
240
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.27-alpha.
|
|
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.27-alpha.
|
|
29
|
-
"@antv/l7-utils": "2.9.27-alpha.
|
|
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.27-alpha.
|
|
38
|
+
"@antv/l7-test-utils": "2.9.27-alpha.2"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "209f0b76af7ad1c7342f5ea21aa1c2179e8c460d",
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
}
|