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