@antv/l7-component 2.9.27-alpha.1 → 2.9.27-alpha.3
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/control/layer.js +2 -2
- package/es/marker-layer.js +34 -27
- package/es/marker.js +18 -16
- package/lib/control/layer.js +2 -2
- package/lib/marker-layer.js +13 -8
- package/lib/marker.js +1 -1
- package/package.json +5 -5
package/es/control/layer.js
CHANGED
|
@@ -148,11 +148,11 @@ var Layers = /*#__PURE__*/function (_Control) {
|
|
|
148
148
|
baseLayers = _this$controlOption$b === void 0 ? {} : _this$controlOption$b,
|
|
149
149
|
_this$controlOption$o = _this$controlOption.overlayers,
|
|
150
150
|
overlayers = _this$controlOption$o === void 0 ? {} : _this$controlOption$o;
|
|
151
|
-
Object.keys(baseLayers).forEach(function (name
|
|
151
|
+
Object.keys(baseLayers).forEach(function (name) {
|
|
152
152
|
// baseLayers[name].once('inited', this.update);
|
|
153
153
|
_this4.addLayer(baseLayers[name], name, false);
|
|
154
154
|
});
|
|
155
|
-
Object.keys(overlayers).forEach(function (name
|
|
155
|
+
Object.keys(overlayers).forEach(function (name) {
|
|
156
156
|
// overlayers[name].once('inited', this.update);
|
|
157
157
|
_this4.addLayer(overlayers[name], name, true);
|
|
158
158
|
});
|
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/es/marker.js
CHANGED
|
@@ -68,9 +68,7 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
68
68
|
this.scene = scene;
|
|
69
69
|
this.mapsService = scene.get(TYPES.IMapService);
|
|
70
70
|
this.sceneSerive = scene.get(TYPES.ISceneService);
|
|
71
|
-
var
|
|
72
|
-
element = _this$markerOption.element,
|
|
73
|
-
draggable = _this$markerOption.draggable; // this.sceneSerive.getSceneContainer().appendChild(element as HTMLElement);
|
|
71
|
+
var element = this.markerOption.element; // this.sceneSerive.getSceneContainer().appendChild(element as HTMLElement);
|
|
74
72
|
|
|
75
73
|
this.mapsService.getMarkerContainer().appendChild(element);
|
|
76
74
|
this.registerMarkerEvent(element);
|
|
@@ -242,7 +240,8 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
242
240
|
key: "getOffset",
|
|
243
241
|
value: function getOffset() {
|
|
244
242
|
return this.markerOption.offsets;
|
|
245
|
-
}
|
|
243
|
+
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
244
|
+
|
|
246
245
|
}, {
|
|
247
246
|
key: "setDraggable",
|
|
248
247
|
value: function setDraggable(draggable) {
|
|
@@ -270,12 +269,13 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
270
269
|
return;
|
|
271
270
|
}
|
|
272
271
|
|
|
273
|
-
var _this$
|
|
274
|
-
element = _this$
|
|
275
|
-
anchor = _this$
|
|
272
|
+
var _this$markerOption = this.markerOption,
|
|
273
|
+
element = _this$markerOption.element,
|
|
274
|
+
anchor = _this$markerOption.anchor;
|
|
276
275
|
this.updatePosition();
|
|
277
276
|
DOM.setTransform(element, "".concat(anchorTranslate[anchor]));
|
|
278
|
-
}
|
|
277
|
+
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
278
|
+
|
|
279
279
|
}, {
|
|
280
280
|
key: "onMapClick",
|
|
281
281
|
value: function onMapClick(e) {
|
|
@@ -302,9 +302,9 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
302
302
|
return;
|
|
303
303
|
}
|
|
304
304
|
|
|
305
|
-
var _this$
|
|
306
|
-
element = _this$
|
|
307
|
-
offsets = _this$
|
|
305
|
+
var _this$markerOption2 = this.markerOption,
|
|
306
|
+
element = _this$markerOption2.element,
|
|
307
|
+
offsets = _this$markerOption2.offsets;
|
|
308
308
|
var _this$lngLat = this.lngLat,
|
|
309
309
|
lng = _this$lngLat.lng,
|
|
310
310
|
lat = _this$lngLat.lat;
|
|
@@ -351,9 +351,9 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
351
351
|
var _this5 = this;
|
|
352
352
|
|
|
353
353
|
var element = this.markerOption.element;
|
|
354
|
-
var _this$
|
|
355
|
-
color = _this$
|
|
356
|
-
anchor = _this$
|
|
354
|
+
var _this$markerOption3 = this.markerOption,
|
|
355
|
+
color = _this$markerOption3.color,
|
|
356
|
+
anchor = _this$markerOption3.anchor;
|
|
357
357
|
|
|
358
358
|
if (!element) {
|
|
359
359
|
this.defaultMarker = true;
|
|
@@ -416,9 +416,11 @@ var Marker = /*#__PURE__*/function (_EventEmitter) {
|
|
|
416
416
|
}
|
|
417
417
|
}, {
|
|
418
418
|
key: "addDragHandler",
|
|
419
|
-
value:
|
|
419
|
+
value: // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
420
|
+
function addDragHandler(e) {
|
|
420
421
|
throw new Error('Method not implemented.');
|
|
421
|
-
}
|
|
422
|
+
} // eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
423
|
+
|
|
422
424
|
}, {
|
|
423
425
|
key: "onUp",
|
|
424
426
|
value: function onUp(e) {
|
package/lib/control/layer.js
CHANGED
|
@@ -121,10 +121,10 @@ var Layers = class extends import_BaseControl.default {
|
|
|
121
121
|
}
|
|
122
122
|
initLayers() {
|
|
123
123
|
const { baseLayers = {}, overlayers = {} } = this.controlOption;
|
|
124
|
-
Object.keys(baseLayers).forEach((name
|
|
124
|
+
Object.keys(baseLayers).forEach((name) => {
|
|
125
125
|
this.addLayer(baseLayers[name], name, false);
|
|
126
126
|
});
|
|
127
|
-
Object.keys(overlayers).forEach((name
|
|
127
|
+
Object.keys(overlayers).forEach((name) => {
|
|
128
128
|
this.addLayer(overlayers[name], name, true);
|
|
129
129
|
});
|
|
130
130
|
}
|
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/lib/marker.js
CHANGED
|
@@ -58,7 +58,7 @@ var Marker = class extends import_eventemitter3.EventEmitter {
|
|
|
58
58
|
this.scene = scene;
|
|
59
59
|
this.mapsService = scene.get(import_l7_core.TYPES.IMapService);
|
|
60
60
|
this.sceneSerive = scene.get(import_l7_core.TYPES.ISceneService);
|
|
61
|
-
const { element
|
|
61
|
+
const { element } = this.markerOption;
|
|
62
62
|
this.mapsService.getMarkerContainer().appendChild(element);
|
|
63
63
|
this.registerMarkerEvent(element);
|
|
64
64
|
this.mapsService.on("camerachange", this.update);
|
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.3",
|
|
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.3",
|
|
29
|
+
"@antv/l7-utils": "2.9.27-alpha.3",
|
|
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.3"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "395ceeac3d64e838604f6acf8a84668488762ee3",
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
}
|