@antv/l7-component 2.15.2 → 2.15.4

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.
Files changed (47) hide show
  1. package/es/assets/iconfont/iconfont.js +10 -17
  2. package/es/control/baseControl/buttonControl.js +9 -42
  3. package/es/control/baseControl/control.js +24 -53
  4. package/es/control/baseControl/popperControl.js +10 -24
  5. package/es/control/baseControl/selectControl.js +6 -45
  6. package/es/control/exportImage.js +76 -116
  7. package/es/control/fullscreen.js +20 -53
  8. package/es/control/geoLocate.js +36 -66
  9. package/es/control/layerSwitch.js +0 -31
  10. package/es/control/logo.js +2 -14
  11. package/es/control/mapTheme.js +7 -32
  12. package/es/control/mouseLocation.js +2 -23
  13. package/es/control/scale.js +6 -29
  14. package/es/control/zoom.js +0 -23
  15. package/es/index.js +2 -12
  16. package/es/marker-layer.js +41 -75
  17. package/es/marker.js +31 -85
  18. package/es/popup/layerPopup.js +31 -82
  19. package/es/popup/popup.js +48 -127
  20. package/es/utils/anchor.js +3 -7
  21. package/es/utils/popper.js +15 -64
  22. package/es/utils/screenfull.js +23 -52
  23. package/lib/assets/iconfont/iconfont.js +10 -17
  24. package/lib/control/baseControl/buttonControl.js +9 -52
  25. package/lib/control/baseControl/control.js +24 -68
  26. package/lib/control/baseControl/index.js +0 -8
  27. package/lib/control/baseControl/popperControl.js +10 -29
  28. package/lib/control/baseControl/selectControl.js +6 -60
  29. package/lib/control/exportImage.js +76 -125
  30. package/lib/control/fullscreen.js +20 -60
  31. package/lib/control/geoLocate.js +36 -75
  32. package/lib/control/layerSwitch.js +0 -36
  33. package/lib/control/logo.js +2 -26
  34. package/lib/control/mapTheme.js +7 -42
  35. package/lib/control/mouseLocation.js +2 -33
  36. package/lib/control/scale.js +6 -40
  37. package/lib/control/zoom.js +0 -33
  38. package/lib/index.js +0 -41
  39. package/lib/marker-layer.js +39 -86
  40. package/lib/marker.js +30 -92
  41. package/lib/popup/layerPopup.js +29 -94
  42. package/lib/popup/popup.js +48 -139
  43. package/lib/utils/anchor.js +4 -9
  44. package/lib/utils/icon.js +0 -2
  45. package/lib/utils/popper.js +14 -71
  46. package/lib/utils/screenfull.js +23 -54
  47. package/package.json +6 -6
@@ -6,46 +6,32 @@ import _inherits from "@babel/runtime/helpers/esm/inherits";
6
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
7
7
  import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
8
8
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
9
-
10
9
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
11
-
12
10
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
13
-
14
11
  import { TYPES } from '@antv/l7-core';
15
12
  import { bindAll, boundsContains, DOM, padBounds, Satistics } from '@antv/l7-utils';
16
13
  import { EventEmitter } from 'eventemitter3';
17
- import { merge } from 'lodash'; // @ts-ignore
14
+ import { merge } from 'lodash';
15
+ // @ts-ignore
18
16
  // tslint:disable-next-line:no-submodule-imports
19
-
20
17
  import Supercluster from 'supercluster/dist/supercluster';
21
18
  import Marker from "./marker";
22
-
23
19
  var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
24
20
  _inherits(MarkerLayer, _EventEmitter);
25
-
26
21
  var _super = _createSuper(MarkerLayer);
27
-
28
22
  function MarkerLayer(option) {
29
23
  var _this$markerLayerOpti;
30
-
31
24
  var _this;
32
-
33
25
  _classCallCheck(this, MarkerLayer);
34
-
35
26
  _this = _super.call(this);
36
-
37
27
  _defineProperty(_assertThisInitialized(_this), "markers", []);
38
-
39
28
  _defineProperty(_assertThisInitialized(_this), "points", []);
40
-
41
29
  _defineProperty(_assertThisInitialized(_this), "clusterMarkers", []);
42
-
43
30
  _this.markerLayerOption = merge(_this.getDefault(), option);
44
31
  bindAll(['update'], _assertThisInitialized(_this));
45
32
  _this.zoom = ((_this$markerLayerOpti = _this.markerLayerOption.clusterOption) === null || _this$markerLayerOpti === void 0 ? void 0 : _this$markerLayerOpti.zoom) || -99;
46
33
  return _this;
47
34
  }
48
-
49
35
  _createClass(MarkerLayer, [{
50
36
  key: "getDefault",
51
37
  value: function getDefault() {
@@ -60,63 +46,60 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
60
46
  className: ''
61
47
  }
62
48
  };
63
- } // 执行scene.addMarkerLayer时调用
49
+ }
64
50
 
51
+ // 执行scene.addMarkerLayer时调用
65
52
  }, {
66
53
  key: "addTo",
67
54
  value: function addTo(scene) {
68
55
  // this.remove();
69
56
  this.scene = scene;
70
57
  this.mapsService = scene.get(TYPES.IMapService);
71
-
72
58
  if (this.markerLayerOption.cluster) {
73
59
  this.initCluster();
74
- this.update(); // 地图视野变化时,重新计算视野内的聚合点。
75
-
60
+ this.update();
61
+ // 地图视野变化时,重新计算视野内的聚合点。
76
62
  this.mapsService.on('camerachange', this.update); // amap1.x 更新事件
77
-
78
63
  this.mapsService.on('viewchange', this.update); // amap2.0 更新事件
79
64
  }
80
65
 
81
66
  this.mapsService.on('camerachange', this.setContainerSize.bind(this)); // amap1.x 更新事件
82
-
83
67
  this.mapsService.on('viewchange', this.setContainerSize.bind(this)); // amap2.0 更新事件
84
-
85
68
  this.addMarkers();
86
69
  this.inited = true;
87
70
  return this;
88
- } // 设置容器大小
71
+ }
89
72
 
73
+ // 设置容器大小
90
74
  }, {
91
75
  key: "setContainerSize",
92
76
  value: function setContainerSize() {
93
77
  if (!this.mapsService) {
94
78
  return;
95
79
  }
96
-
97
80
  var container = this.mapsService.getContainer();
98
81
  this.containerSize = {
99
82
  containerWidth: (container === null || container === void 0 ? void 0 : container.scrollWidth) || 0,
100
83
  containerHeight: (container === null || container === void 0 ? void 0 : container.scrollHeight) || 0,
101
84
  bounds: this.mapsService.getBounds()
102
85
  };
103
- } // 获取容器尺寸
86
+ }
104
87
 
88
+ // 获取容器尺寸
105
89
  }, {
106
90
  key: "getContainerSize",
107
91
  value: function getContainerSize() {
108
92
  return this.containerSize;
109
- } // 在图层添加单个marker
93
+ }
110
94
 
95
+ // 在图层添加单个marker
111
96
  }, {
112
97
  key: "addMarker",
113
98
  value: function addMarker(marker) {
114
99
  var cluster = this.markerLayerOption.cluster;
115
100
  marker.getMarkerLayerContainerSize = this.getContainerSize.bind(this);
116
-
117
101
  if (cluster) {
118
102
  this.addPoint(marker, this.markers.length);
119
-
120
103
  if (this.mapsService) {
121
104
  // 在新增 marker 的时候需要更新聚合信息(哪怕此时的 zoom 没有发生变化)
122
105
  var zoom = this.mapsService.getZoom();
@@ -126,8 +109,8 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
126
109
  this.getClusterMarker(this.bbox, this.zoom);
127
110
  }
128
111
  }
129
-
130
- this.markers.push(marker); // if(this.inited) {
112
+ this.markers.push(marker);
113
+ // if(this.inited) {
131
114
  // marker.addTo(this.scene);
132
115
  // }
133
116
  }
@@ -136,15 +119,14 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
136
119
  value: function removeMarker(marker) {
137
120
  this.markers.indexOf(marker);
138
121
  var markerIndex = this.markers.indexOf(marker);
139
-
140
122
  if (markerIndex > -1) {
141
123
  this.markers.splice(markerIndex, 1);
142
124
  }
143
125
  }
126
+
144
127
  /**
145
128
  * 隐藏 marker 在每个 marker 上单独修改属性而不是在 markerContainer 上修改(在 markerContainer 修改会有用户在场景加载完之前调用失败的问题)
146
129
  */
147
-
148
130
  }, {
149
131
  key: "hide",
150
132
  value: function hide() {
@@ -155,10 +137,10 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
155
137
  m.getElement().style.opacity = '0';
156
138
  });
157
139
  }
140
+
158
141
  /**
159
142
  * 显示 marker
160
143
  */
161
-
162
144
  }, {
163
145
  key: "show",
164
146
  value: function show() {
@@ -168,25 +150,27 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
168
150
  this.clusterMarkers.map(function (m) {
169
151
  m.getElement().style.opacity = '1';
170
152
  });
171
- } // 返回当下的markers数据,有聚合图时返回聚合的marker列表,否则返回原始maerker列表
153
+ }
172
154
 
155
+ // 返回当下的markers数据,有聚合图时返回聚合的marker列表,否则返回原始maerker列表
173
156
  }, {
174
157
  key: "getMarkers",
175
158
  value: function getMarkers() {
176
159
  var cluster = this.markerLayerOption.cluster;
177
160
  return cluster ? this.clusterMarkers : this.markers;
178
- } // 批量添加marker到scene
161
+ }
179
162
 
163
+ // 批量添加marker到scene
180
164
  }, {
181
165
  key: "addMarkers",
182
166
  value: function addMarkers() {
183
167
  var _this2 = this;
184
-
185
168
  this.getMarkers().forEach(function (marker) {
186
169
  marker.addTo(_this2.scene);
187
170
  });
188
- } // 清除图层里的marker
171
+ }
189
172
 
173
+ // 清除图层里的marker
190
174
  }, {
191
175
  key: "clear",
192
176
  value: function clear() {
@@ -209,15 +193,15 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
209
193
  this.mapsService.off('viewchange', this.update);
210
194
  this.mapsService.off('camerachange', this.setContainerSize.bind(this));
211
195
  this.mapsService.off('viewchange', this.setContainerSize.bind(this));
212
- } // 将marker数据保存在point中
196
+ }
213
197
 
198
+ // 将marker数据保存在point中
214
199
  }, {
215
200
  key: "addPoint",
216
201
  value: function addPoint(marker, id) {
217
202
  var _marker$getLnglat = marker.getLnglat(),
218
- lng = _marker$getLnglat.lng,
219
- lat = _marker$getLnglat.lat;
220
-
203
+ lng = _marker$getLnglat.lng,
204
+ lat = _marker$getLnglat.lat;
221
205
  var feature = {
222
206
  geometry: {
223
207
  type: 'Point',
@@ -228,7 +212,6 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
228
212
  })
229
213
  };
230
214
  this.points.push(feature);
231
-
232
215
  if (this.clusterIndex) {
233
216
  // 在新增点的时候需要更新 cluster 的数据
234
217
  this.clusterIndex.load(this.points);
@@ -240,25 +223,23 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
240
223
  if (!this.markerLayerOption.cluster) {
241
224
  return;
242
225
  }
243
-
244
226
  var _this$markerLayerOpti2 = this.markerLayerOption.clusterOption,
245
- radius = _this$markerLayerOpti2.radius,
246
- _this$markerLayerOpti3 = _this$markerLayerOpti2.minZoom,
247
- minZoom = _this$markerLayerOpti3 === void 0 ? 0 : _this$markerLayerOpti3,
248
- maxZoom = _this$markerLayerOpti2.maxZoom;
227
+ radius = _this$markerLayerOpti2.radius,
228
+ _this$markerLayerOpti3 = _this$markerLayerOpti2.minZoom,
229
+ minZoom = _this$markerLayerOpti3 === void 0 ? 0 : _this$markerLayerOpti3,
230
+ maxZoom = _this$markerLayerOpti2.maxZoom;
249
231
  this.clusterIndex = new Supercluster({
250
232
  radius: radius,
251
233
  minZoom: minZoom,
252
234
  maxZoom: maxZoom
253
- }); // @ts-ignore
254
-
235
+ });
236
+ // @ts-ignore
255
237
  this.clusterIndex.load(this.points);
256
238
  }
257
239
  }, {
258
240
  key: "getClusterMarker",
259
241
  value: function getClusterMarker(viewBounds, zoom) {
260
242
  var _this3 = this;
261
-
262
243
  var viewBBox = viewBounds[0].concat(viewBounds[1]);
263
244
  var clusterPoint = this.clusterIndex.getClusters(viewBBox, zoom);
264
245
  this.clusterMarkers.forEach(function (marker) {
@@ -267,22 +248,17 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
267
248
  this.clusterMarkers = [];
268
249
  clusterPoint.forEach(function (feature) {
269
250
  var _feature$properties;
270
-
271
251
  var _this3$markerLayerOpt = _this3.markerLayerOption.clusterOption,
272
- field = _this3$markerLayerOpt.field,
273
- method = _this3$markerLayerOpt.method; // 处理聚合数据
274
-
252
+ field = _this3$markerLayerOpt.field,
253
+ method = _this3$markerLayerOpt.method;
254
+ // 处理聚合数据
275
255
  if ((_feature$properties = feature.properties) !== null && _feature$properties !== void 0 && _feature$properties.cluster_id) {
276
256
  var _feature$properties2;
277
-
278
257
  var clusterData = _this3.getLeaves((_feature$properties2 = feature.properties) === null || _feature$properties2 === void 0 ? void 0 : _feature$properties2.cluster_id);
279
-
280
258
  feature.properties.clusterData = clusterData;
281
-
282
259
  if (field && method) {
283
260
  var columnData = clusterData === null || clusterData === void 0 ? void 0 : clusterData.map(function (item) {
284
261
  var data = _defineProperty({}, field, item.properties[field]);
285
-
286
262
  return data;
287
263
  });
288
264
  var column = Satistics.getColumn(columnData, field);
@@ -291,11 +267,8 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
291
267
  feature.properties[fieldName] = stat.toFixed(2);
292
268
  }
293
269
  }
294
-
295
270
  var marker = _this3.clusterMarker(feature);
296
-
297
271
  _this3.clusterMarkers.push(marker);
298
-
299
272
  marker.addTo(_this3.scene);
300
273
  });
301
274
  }
@@ -304,11 +277,9 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
304
277
  value: function getLeaves(clusterId) {
305
278
  var limit = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
306
279
  var offset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
307
-
308
280
  if (!clusterId) {
309
281
  return null;
310
282
  }
311
-
312
283
  return this.clusterIndex.getLeaves(clusterId, limit, offset);
313
284
  }
314
285
  }, {
@@ -316,8 +287,8 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
316
287
  value: function clusterMarker(feature) {
317
288
  var clusterOption = this.markerLayerOption.clusterOption;
318
289
  var _ref = clusterOption,
319
- _ref$element = _ref.element,
320
- element = _ref$element === void 0 ? this.generateElement.bind(this) : _ref$element;
290
+ _ref$element = _ref.element,
291
+ element = _ref$element === void 0 ? this.generateElement.bind(this) : _ref$element;
321
292
  var marker = new Marker({
322
293
  element: element(feature)
323
294
  }).setLnglat({
@@ -337,16 +308,13 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
337
308
  value: function update() {
338
309
  if (!this.mapsService) {
339
310
  return;
340
- } // 当图层中无marker时,无需更新
341
-
342
-
311
+ }
312
+ // 当图层中无marker时,无需更新
343
313
  if (this.markers.length === 0) {
344
314
  return;
345
315
  }
346
-
347
316
  var zoom = this.mapsService.getZoom();
348
317
  var bbox = this.mapsService.getBounds();
349
-
350
318
  if (!this.bbox || Math.abs(zoom - this.zoom) >= 1 || !boundsContains(this.bbox, bbox)) {
351
319
  this.bbox = padBounds(bbox, 0.5);
352
320
  this.zoom = Math.floor(zoom);
@@ -360,16 +328,14 @@ var MarkerLayer = /*#__PURE__*/function (_EventEmitter) {
360
328
  var label = DOM.create('div', '', el);
361
329
  var span = DOM.create('span', '', label);
362
330
  var _this$markerLayerOpti4 = this.markerLayerOption.clusterOption,
363
- field = _this$markerLayerOpti4.field,
364
- method = _this$markerLayerOpti4.method;
331
+ field = _this$markerLayerOpti4.field,
332
+ method = _this$markerLayerOpti4.method;
365
333
  feature.properties.point_count = feature.properties.point_count || 1;
366
334
  var text = field && method ? feature.properties['point_' + method] || feature.properties[field] : feature.properties.point_count;
367
335
  span.textContent = text;
368
336
  return el;
369
337
  }
370
338
  }]);
371
-
372
339
  return MarkerLayer;
373
340
  }(EventEmitter);
374
-
375
341
  export { MarkerLayer as default };