@antv/l7-component 2.25.5 → 2.25.7

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 (151) hide show
  1. package/package.json +5 -5
  2. package/es/assets/iconfont/iconfont.d.ts +0 -21
  3. package/es/assets/iconfont/iconfont.js +0 -61
  4. package/es/constants/index.d.ts +0 -60
  5. package/es/constants/index.js +0 -60
  6. package/es/control/baseControl/buttonControl.d.ts +0 -60
  7. package/es/control/baseControl/buttonControl.js +0 -142
  8. package/es/control/baseControl/control.d.ts +0 -112
  9. package/es/control/baseControl/control.js +0 -256
  10. package/es/control/baseControl/index.d.ts +0 -4
  11. package/es/control/baseControl/index.js +0 -4
  12. package/es/control/baseControl/popperControl.d.ts +0 -28
  13. package/es/control/baseControl/popperControl.js +0 -92
  14. package/es/control/baseControl/selectControl.d.ts +0 -53
  15. package/es/control/baseControl/selectControl.js +0 -173
  16. package/es/control/exportImage.d.ts +0 -19
  17. package/es/control/exportImage.js +0 -73
  18. package/es/control/fullscreen.d.ts +0 -20
  19. package/es/control/fullscreen.js +0 -88
  20. package/es/control/geoLocate.d.ts +0 -17
  21. package/es/control/geoLocate.js +0 -60
  22. package/es/control/layerSwitch.d.ts +0 -27
  23. package/es/control/layerSwitch.js +0 -155
  24. package/es/control/logo.d.ts +0 -14
  25. package/es/control/logo.js +0 -49
  26. package/es/control/mapTheme.d.ts +0 -11
  27. package/es/control/mapTheme.js +0 -69
  28. package/es/control/mouseLocation.d.ts +0 -16
  29. package/es/control/mouseLocation.js +0 -52
  30. package/es/control/scale.d.ts +0 -35
  31. package/es/control/scale.js +0 -121
  32. package/es/control/swipe.d.ts +0 -66
  33. package/es/control/swipe.js +0 -392
  34. package/es/control/zoom.d.ts +0 -39
  35. package/es/control/zoom.js +0 -100
  36. package/es/css/button.less +0 -77
  37. package/es/css/control.less +0 -82
  38. package/es/css/index.css +0 -653
  39. package/es/css/index.less +0 -13
  40. package/es/css/l7.less +0 -69
  41. package/es/css/layerPopup.less +0 -9
  42. package/es/css/logo.less +0 -21
  43. package/es/css/mouseLocation.less +0 -9
  44. package/es/css/popper.less +0 -74
  45. package/es/css/popup.less +0 -176
  46. package/es/css/scale.less +0 -37
  47. package/es/css/select.less +0 -96
  48. package/es/css/swipe.less +0 -80
  49. package/es/css/variables.less +0 -29
  50. package/es/css/zoom.less +0 -34
  51. package/es/images/layers.png +0 -0
  52. package/es/images/layers.svg +0 -1
  53. package/es/images/logo.png +0 -0
  54. package/es/images/quanping.svg +0 -12
  55. package/es/index.d.ts +0 -19
  56. package/es/index.js +0 -708
  57. package/es/interface.d.ts +0 -29
  58. package/es/interface.js +0 -1
  59. package/es/marker-layer.d.ts +0 -46
  60. package/es/marker-layer.js +0 -509
  61. package/es/marker.d.ts +0 -66
  62. package/es/marker.js +0 -495
  63. package/es/popup/layerPopup.d.ts +0 -105
  64. package/es/popup/layerPopup.js +0 -341
  65. package/es/popup/popup.d.ts +0 -147
  66. package/es/popup/popup.js +0 -587
  67. package/es/utils/anchor.d.ts +0 -22
  68. package/es/utils/anchor.js +0 -31
  69. package/es/utils/eventManager.d.ts +0 -42
  70. package/es/utils/eventManager.js +0 -84
  71. package/es/utils/icon.d.ts +0 -1
  72. package/es/utils/icon.js +0 -12
  73. package/es/utils/popper.d.ts +0 -76
  74. package/es/utils/popper.js +0 -257
  75. package/es/utils/screenfull.d.ts +0 -2
  76. package/es/utils/screenfull.js +0 -106
  77. package/lib/assets/iconfont/iconfont.d.ts +0 -21
  78. package/lib/assets/iconfont/iconfont.js +0 -68
  79. package/lib/constants/index.d.ts +0 -60
  80. package/lib/constants/index.js +0 -66
  81. package/lib/control/baseControl/buttonControl.d.ts +0 -60
  82. package/lib/control/baseControl/buttonControl.js +0 -149
  83. package/lib/control/baseControl/control.d.ts +0 -112
  84. package/lib/control/baseControl/control.js +0 -269
  85. package/lib/control/baseControl/index.d.ts +0 -4
  86. package/lib/control/baseControl/index.js +0 -39
  87. package/lib/control/baseControl/popperControl.d.ts +0 -28
  88. package/lib/control/baseControl/popperControl.js +0 -99
  89. package/lib/control/baseControl/selectControl.d.ts +0 -53
  90. package/lib/control/baseControl/selectControl.js +0 -180
  91. package/lib/control/exportImage.d.ts +0 -19
  92. package/lib/control/exportImage.js +0 -80
  93. package/lib/control/fullscreen.d.ts +0 -20
  94. package/lib/control/fullscreen.js +0 -95
  95. package/lib/control/geoLocate.d.ts +0 -17
  96. package/lib/control/geoLocate.js +0 -67
  97. package/lib/control/layerSwitch.d.ts +0 -27
  98. package/lib/control/layerSwitch.js +0 -162
  99. package/lib/control/logo.d.ts +0 -14
  100. package/lib/control/logo.js +0 -55
  101. package/lib/control/mapTheme.d.ts +0 -11
  102. package/lib/control/mapTheme.js +0 -76
  103. package/lib/control/mouseLocation.d.ts +0 -16
  104. package/lib/control/mouseLocation.js +0 -59
  105. package/lib/control/scale.d.ts +0 -35
  106. package/lib/control/scale.js +0 -128
  107. package/lib/control/swipe.d.ts +0 -66
  108. package/lib/control/swipe.js +0 -399
  109. package/lib/control/zoom.d.ts +0 -39
  110. package/lib/control/zoom.js +0 -107
  111. package/lib/css/button.less +0 -77
  112. package/lib/css/control.less +0 -82
  113. package/lib/css/index.css +0 -653
  114. package/lib/css/index.less +0 -13
  115. package/lib/css/l7.less +0 -69
  116. package/lib/css/layerPopup.less +0 -9
  117. package/lib/css/logo.less +0 -21
  118. package/lib/css/mouseLocation.less +0 -9
  119. package/lib/css/popper.less +0 -74
  120. package/lib/css/popup.less +0 -176
  121. package/lib/css/scale.less +0 -37
  122. package/lib/css/select.less +0 -96
  123. package/lib/css/swipe.less +0 -80
  124. package/lib/css/variables.less +0 -29
  125. package/lib/css/zoom.less +0 -34
  126. package/lib/images/layers.png +0 -0
  127. package/lib/images/layers.svg +0 -1
  128. package/lib/images/logo.png +0 -0
  129. package/lib/images/quanping.svg +0 -12
  130. package/lib/index.d.ts +0 -19
  131. package/lib/index.js +0 -835
  132. package/lib/interface.d.ts +0 -29
  133. package/lib/interface.js +0 -5
  134. package/lib/marker-layer.d.ts +0 -46
  135. package/lib/marker-layer.js +0 -518
  136. package/lib/marker.d.ts +0 -66
  137. package/lib/marker.js +0 -502
  138. package/lib/popup/layerPopup.d.ts +0 -105
  139. package/lib/popup/layerPopup.js +0 -348
  140. package/lib/popup/popup.d.ts +0 -147
  141. package/lib/popup/popup.js +0 -594
  142. package/lib/utils/anchor.d.ts +0 -22
  143. package/lib/utils/anchor.js +0 -38
  144. package/lib/utils/eventManager.d.ts +0 -42
  145. package/lib/utils/eventManager.js +0 -92
  146. package/lib/utils/icon.d.ts +0 -1
  147. package/lib/utils/icon.js +0 -19
  148. package/lib/utils/popper.d.ts +0 -76
  149. package/lib/utils/popper.js +0 -264
  150. package/lib/utils/screenfull.d.ts +0 -2
  151. package/lib/utils/screenfull.js +0 -112
package/lib/marker.js DELETED
@@ -1,502 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
- Object.defineProperty(exports, "__esModule", {
5
- value: true
6
- });
7
- exports.default = void 0;
8
- var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
9
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
- var _l7Utils = require("@antv/l7-utils");
11
- var _eventemitter = require("eventemitter3");
12
- // marker 支持 dragger 未完成
13
- class Marker extends _eventemitter.EventEmitter {
14
- // tslint:disable-next-line: no-empty
15
- getMarkerLayerContainerSize() {}
16
- constructor(option) {
17
- super();
18
- (0, _defineProperty2.default)(this, "markerOption", void 0);
19
- (0, _defineProperty2.default)(this, "popup", void 0);
20
- (0, _defineProperty2.default)(this, "mapsService", void 0);
21
- (0, _defineProperty2.default)(this, "lngLat", void 0);
22
- (0, _defineProperty2.default)(this, "scene", void 0);
23
- (0, _defineProperty2.default)(this, "added", false);
24
- (0, _defineProperty2.default)(this, "preLngLat", {
25
- lng: 0,
26
- lat: 0
27
- });
28
- (0, _defineProperty2.default)(this, "visible", true);
29
- (0, _defineProperty2.default)(this, "onMarkerDragStart", e => {
30
- const mapContainer = this.mapsService.getContainer();
31
- if (!mapContainer) {
32
- return;
33
- }
34
- this.mapsService.setMapStatus({
35
- dragEnable: false,
36
- zoomEnable: false
37
- });
38
- const {
39
- left: containerX,
40
- top: containerY
41
- } = mapContainer.getClientRects()[0];
42
- const {
43
- x: clickX,
44
- y: clickY
45
- } = e;
46
- this.preLngLat = this.mapsService.containerToLngLat([clickX - containerX, clickY - containerY]);
47
- this.mapsService.on('mousemove', this.onMarkerDragMove);
48
- document.addEventListener('mouseup', this.onMarkerDragEnd);
49
- this.emit('dragstart', this.lngLat);
50
- });
51
- (0, _defineProperty2.default)(this, "onMarkerDragMove", e => {
52
- // 适配不同底图,事件返回的数据名称不一致
53
- const lngLat = e.lngLat || e.lnglat;
54
- const {
55
- lng: preLng,
56
- lat: preLat
57
- } = this.preLngLat;
58
- const {
59
- lng: curLng,
60
- lat: curLat
61
- } = lngLat;
62
- const newLngLat = {
63
- lng: this.lngLat.lng + curLng - preLng,
64
- lat: this.lngLat.lat + curLat - preLat
65
- };
66
- this.setLnglat(newLngLat);
67
- this.preLngLat = lngLat;
68
- this.emit('dragging', newLngLat);
69
- });
70
- (0, _defineProperty2.default)(this, "onMarkerDragEnd", () => {
71
- this.mapsService.setMapStatus({
72
- dragEnable: true,
73
- zoomEnable: true
74
- });
75
- this.mapsService.off('mousemove', this.onMarkerDragMove);
76
- document.removeEventListener('mouseup', this.onMarkerDragEnd);
77
- this.emit('dragend', this.lngLat);
78
- });
79
- (0, _defineProperty2.default)(this, "eventHandle", e => {
80
- this.polyfillEvent(e);
81
- this.emit(e.type, {
82
- target: e,
83
- data: this.markerOption.extData,
84
- lngLat: this.lngLat
85
- });
86
- });
87
- /**
88
- * 高德 2.x 使用了 fastClick.js 避免延迟,导致 IOS 移动端的 click 事件不会正常触发,需要手动触发
89
- * @param e
90
- */
91
- (0, _defineProperty2.default)(this, "touchStartTime", void 0);
92
- this.markerOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.getDefault()), option);
93
- (0, _l7Utils.bindAll)(['update', 'onMove', 'onMapClick', 'updatePositionWhenZoom'], this);
94
- this.init();
95
- }
96
- getDefault() {
97
- return {
98
- element: undefined,
99
- // DOM element
100
- anchor: _l7Utils.anchorType.BOTTOM,
101
- offsets: [0, 0],
102
- color: '#5B8FF9',
103
- draggable: false,
104
- overflowHide: true
105
- };
106
- }
107
- addTo(scene) {
108
- this.scene = scene;
109
- this.mapsService = scene.mapService;
110
- const {
111
- element
112
- } = this.markerOption;
113
- this.mapsService.getMarkerContainer().appendChild(element);
114
- this.registerMarkerEvent(element);
115
- // marker 不再在自身注册地图相机事件,以避免为每个 marker 注册大量底层 map 监听器。
116
- // 由 MarkerLayer 在 addTo 时统一注册并在相机变化时调用每个 marker.update()。
117
- this.update();
118
- this.updateDraggable();
119
- this.added = true;
120
- this.emit('added');
121
- return this;
122
- }
123
- remove() {
124
- if (this.mapsService) {
125
- // 不再负责移除地图级别的 update 监听(由 MarkerLayer 管理),移除地图事件请统一通过 layer
126
- }
127
- this.unRegisterMarkerEvent();
128
- this.removeAllListeners();
129
- const {
130
- element
131
- } = this.markerOption;
132
- if (element) {
133
- _l7Utils.DOM.remove(element);
134
- }
135
- if (this.popup) {
136
- this.popup.remove();
137
- }
138
- return this;
139
- }
140
-
141
- /**
142
- * Hide the marker visually but keep it in the layer's data structures.
143
- */
144
- hide() {
145
- const {
146
- element
147
- } = this.markerOption;
148
- if (element) {
149
- element.style.display = 'none';
150
- }
151
- this.visible = false;
152
- return this;
153
- }
154
-
155
- /**
156
- * Show the marker if it was hidden.
157
- */
158
- show() {
159
- const {
160
- element
161
- } = this.markerOption;
162
- if (element) {
163
- element.style.display = 'block';
164
- }
165
- this.visible = true;
166
- // re-position after showing
167
- this.update();
168
- return this;
169
- }
170
- setLnglat(lngLat) {
171
- this.lngLat = lngLat;
172
- if (Array.isArray(lngLat)) {
173
- this.lngLat = {
174
- lng: lngLat[0],
175
- lat: lngLat[1]
176
- };
177
- }
178
- if (this.popup) {
179
- this.popup.setLnglat(this.lngLat);
180
- }
181
- this.update();
182
- return this;
183
- }
184
- getLnglat() {
185
- return this.lngLat;
186
- }
187
- getElement() {
188
- return this.markerOption.element;
189
- }
190
- setElement(el) {
191
- if (!this.added) {
192
- this.once('added', () => {
193
- this.setElement(el);
194
- });
195
- return this;
196
- }
197
- const {
198
- element
199
- } = this.markerOption;
200
- if (element) {
201
- _l7Utils.DOM.remove(element);
202
- }
203
- this.markerOption.element = el;
204
- this.init();
205
- this.mapsService.getMarkerContainer().appendChild(el);
206
- this.registerMarkerEvent(el);
207
- this.updateDraggable();
208
- this.update();
209
- return this;
210
- }
211
- openPopup() {
212
- if (!this.added) {
213
- this.once('added', () => {
214
- this.openPopup();
215
- });
216
- return this;
217
- }
218
- const popup = this.popup;
219
- if (!popup) {
220
- return this;
221
- }
222
- if (!popup.isOpen()) {
223
- popup.addTo(this.scene);
224
- }
225
- return this;
226
- }
227
- closePopup() {
228
- if (!this.added) {
229
- this.once('added', () => {
230
- this.closePopup();
231
- });
232
- }
233
- const popup = this.popup;
234
- if (popup) {
235
- popup.remove();
236
- }
237
- return this;
238
- }
239
- setPopup(popup) {
240
- this.popup = popup;
241
- if (this.lngLat) {
242
- this.popup.setLnglat(this.lngLat);
243
- }
244
- return this;
245
- }
246
- togglePopup() {
247
- const popup = this.popup;
248
- if (!popup) {
249
- return this;
250
- } else if (popup.isOpen()) {
251
- popup.remove();
252
- } else {
253
- popup.addTo(this.scene);
254
- }
255
- return this;
256
- }
257
- getPopup() {
258
- return this.popup;
259
- }
260
- getOffset() {
261
- return this.markerOption.offsets;
262
- }
263
- setDraggable(draggable) {
264
- this.markerOption.draggable = draggable;
265
- this.updateDraggable();
266
- }
267
- getDraggable() {
268
- return this.markerOption.draggable;
269
- }
270
- getExtData() {
271
- return this.markerOption.extData;
272
- }
273
- setExtData(data) {
274
- this.markerOption.extData = data;
275
- }
276
- update() {
277
- if (!this.mapsService) {
278
- return;
279
- }
280
- const {
281
- element,
282
- anchor
283
- } = this.markerOption;
284
- this.updatePosition();
285
- _l7Utils.DOM.setTransform(element, `${_l7Utils.anchorTranslate[anchor]}`);
286
- }
287
- //天地图在开始缩放时触发 更新目标位置时添加过渡效果
288
- updatePositionWhenZoom(ev) {
289
- if (!this.mapsService) {
290
- return;
291
- }
292
- const {
293
- element,
294
- offsets
295
- } = this.markerOption;
296
- const {
297
- lng,
298
- lat
299
- } = this.lngLat;
300
- if (!this.visible) {
301
- return;
302
- }
303
- if (element) {
304
- element.style.display = 'block';
305
- element.style.whiteSpace = 'nowrap';
306
- const {
307
- containerHeight,
308
- containerWidth,
309
- bounds
310
- } = this.getMarkerLayerContainerSize() || this.getCurrentContainerSize();
311
- if (!bounds) {
312
- return;
313
- }
314
- const map = ev.map;
315
- const center = ev.center;
316
- const zoom = ev.zoom;
317
- const projectedCenter = map.DE(this.lngLat, zoom, center);
318
- projectedCenter.x = Math.round(projectedCenter.x + offsets[0]);
319
- projectedCenter.y = Math.round(projectedCenter.y - offsets[1]);
320
- // 当前可视区域包含跨日界线
321
- if (Math.abs(bounds[0][0]) > 180 || Math.abs(bounds[1][0]) > 180) {
322
- if (projectedCenter.x > containerWidth) {
323
- // 日界线右侧点左移
324
- const newPos = this.mapsService.lngLatToContainer([lng - 360, lat]);
325
- projectedCenter.x = newPos.x;
326
- }
327
- if (projectedCenter.x < 0) {
328
- // 日界线左侧点右移
329
- const newPos = this.mapsService.lngLatToContainer([lng + 360, lat]);
330
- projectedCenter.x = newPos.x;
331
- }
332
- }
333
- if (projectedCenter.x > containerWidth || projectedCenter.x < 0 || projectedCenter.y > containerHeight || projectedCenter.y < 0) {
334
- element.style.display = 'none';
335
- }
336
- element.style.left = projectedCenter.x + 'px';
337
- element.style.top = projectedCenter.y + 'px';
338
- element.style.transition = 'left 0.25s cubic-bezier(0,0,0.25,1), top 0.25s cubic-bezier(0,0,0.25,1)';
339
- }
340
- }
341
- onMapClick(e) {
342
- const {
343
- element
344
- } = this.markerOption;
345
- if (this.popup && element) {
346
- this.togglePopup();
347
- }
348
- }
349
- getCurrentContainerSize() {
350
- const container = this.mapsService.getContainer();
351
- return {
352
- containerHeight: (container === null || container === void 0 ? void 0 : container.scrollHeight) || 0,
353
- containerWidth: (container === null || container === void 0 ? void 0 : container.scrollWidth) || 0,
354
- bounds: this.mapsService.getBounds()
355
- };
356
- }
357
- updateDraggable() {
358
- const {
359
- element
360
- } = this.markerOption;
361
- element === null || element === void 0 || element.removeEventListener('mousedown', this.onMarkerDragStart);
362
- this.mapsService.off('mousemove', this.onMarkerDragMove);
363
- document.removeEventListener('mouseup', this.onMarkerDragEnd);
364
- if (this.markerOption.draggable) {
365
- element === null || element === void 0 || element.addEventListener('mousedown', this.onMarkerDragStart);
366
- }
367
- }
368
- updatePosition() {
369
- if (!this.mapsService) {
370
- return;
371
- }
372
- const {
373
- element,
374
- offsets
375
- } = this.markerOption;
376
- const {
377
- lng,
378
- lat
379
- } = this.lngLat;
380
- const pos = this.mapsService.lngLatToContainer([lng, lat]);
381
- if (!this.visible) {
382
- // remain hidden until show() is called
383
- if (element) {
384
- element.style.display = 'none';
385
- }
386
- return;
387
- }
388
- if (element) {
389
- element.style.display = 'block';
390
- element.style.whiteSpace = 'nowrap';
391
- const {
392
- containerHeight,
393
- containerWidth,
394
- bounds
395
- } = this.getMarkerLayerContainerSize() || this.getCurrentContainerSize();
396
- if (!bounds) {
397
- return;
398
- }
399
- // 当前可视区域包含跨日界线
400
- if (Math.abs(bounds[0][0]) > 180 || Math.abs(bounds[1][0]) > 180) {
401
- if (pos.x > containerWidth) {
402
- // 日界线右侧点左移
403
- const newPos = this.mapsService.lngLatToContainer([lng - 360, lat]);
404
- pos.x = newPos.x;
405
- }
406
- if (pos.x < 0) {
407
- // 日界线左侧点右移
408
- const newPos = this.mapsService.lngLatToContainer([lng + 360, lat]);
409
- pos.x = newPos.x;
410
- }
411
- }
412
- if (this.markerOption.overflowHide) {
413
- // 不在当前可视区域内隐藏点
414
- if (pos.x > containerWidth || pos.x < 0 || pos.y > containerHeight || pos.y < 0) {
415
- element.style.display = 'none';
416
- }
417
- }
418
- element.style.left = pos.x + offsets[0] + 'px';
419
- element.style.top = pos.y - offsets[1] + 'px';
420
- }
421
- }
422
- init() {
423
- let {
424
- element
425
- } = this.markerOption;
426
- const {
427
- color,
428
- anchor
429
- } = this.markerOption;
430
- if (!element) {
431
- element = _l7Utils.DOM.create('div');
432
- this.markerOption.element = element;
433
- const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
434
- svg.setAttributeNS(null, 'display', 'block');
435
- svg.setAttributeNS(null, 'height', '48px');
436
- svg.setAttributeNS(null, 'width', '48px');
437
- svg.setAttributeNS(null, 'viewBox', '0 0 1024 1024');
438
- const path = document.createElementNS('http://www.w3.org/2000/svg', 'path');
439
- path.setAttributeNS(null, 'd', 'M512 490.666667C453.12 490.666667 405.333333 442.88 405.333333 384 405.333333 325.12 453.12 277.333333 512 277.333333 570.88 277.333333 618.666667 325.12 618.666667 384 618.666667 442.88 570.88 490.666667 512 490.666667M512 85.333333C346.88 85.333333 213.333333 218.88 213.333333 384 213.333333 608 512 938.666667 512 938.666667 512 938.666667 810.666667 608 810.666667 384 810.666667 218.88 677.12 85.333333 512 85.333333Z');
440
- path.setAttributeNS(null, 'fill', color);
441
- svg.appendChild(path);
442
- element.appendChild(svg);
443
- }
444
- _l7Utils.DOM.addClass(element, 'l7-marker');
445
- Object.keys(this.markerOption.style || {}).forEach(
446
- // @ts-ignore
447
- key => {
448
- var _this$markerOption, _this$markerOption2;
449
- const value = ((_this$markerOption = this.markerOption) === null || _this$markerOption === void 0 ? void 0 : _this$markerOption.style) && ((_this$markerOption2 = this.markerOption) === null || _this$markerOption2 === void 0 ? void 0 : _this$markerOption2.style[key]);
450
- if (element) {
451
- // @ts-ignore
452
- element.style[key] = value;
453
- }
454
- });
455
- (0, _l7Utils.applyAnchorClass)(element, anchor, 'marker');
456
- }
457
- registerMarkerEvent(element) {
458
- element.addEventListener('click', this.onMapClick);
459
- element.addEventListener('mousemove', this.eventHandle);
460
- element.addEventListener('click', this.eventHandle);
461
- element.addEventListener('mousedown', this.eventHandle);
462
- element.addEventListener('mouseup', this.eventHandle);
463
- element.addEventListener('dblclick', this.eventHandle);
464
- element.addEventListener('contextmenu', this.eventHandle);
465
- element.addEventListener('mouseover', this.eventHandle);
466
- element.addEventListener('mouseout', this.eventHandle);
467
- element.addEventListener('touchstart', this.eventHandle);
468
- element.addEventListener('touchend', this.eventHandle);
469
- }
470
- unRegisterMarkerEvent() {
471
- const element = this.getElement();
472
- element.removeEventListener('click', this.onMapClick);
473
- element.removeEventListener('mousemove', this.eventHandle);
474
- element.removeEventListener('click', this.eventHandle);
475
- element.removeEventListener('mousedown', this.eventHandle);
476
- element.removeEventListener('mouseup', this.eventHandle);
477
- element.removeEventListener('dblclick', this.eventHandle);
478
- element.removeEventListener('contextmenu', this.eventHandle);
479
- element.removeEventListener('mouseover', this.eventHandle);
480
- element.removeEventListener('mouseout', this.eventHandle);
481
- element.removeEventListener('touchstart', this.eventHandle);
482
- element.removeEventListener('touchend', this.eventHandle);
483
- }
484
- polyfillEvent(e) {
485
- if (!this.mapsService || this.mapsService.getType() !== 'amap') {
486
- return;
487
- }
488
- if (!(0, _l7Utils.isPC)()) {
489
- if (e.type === 'touchstart') {
490
- this.touchStartTime = Date.now();
491
- }
492
- if (e.type === 'touchend' && Date.now() - this.touchStartTime < 300) {
493
- this.emit('click', {
494
- target: e,
495
- data: this.markerOption.extData,
496
- lngLat: this.lngLat
497
- });
498
- }
499
- }
500
- }
501
- }
502
- exports.default = Marker;
@@ -1,105 +0,0 @@
1
- import type { ILayer, IPopupOption, L7Container } from '@antv/l7-core';
2
- import { DOM } from '@antv/l7-utils';
3
- import Popup from './popup';
4
- type ElementType = DOM.ElementType;
5
- export type LayerField = {
6
- field: string;
7
- formatField?: ElementType | ((field: string, feature: any) => ElementType);
8
- formatValue?: ElementType | ((value: any, feature: any) => ElementType);
9
- getValue?: (feature: any) => any;
10
- };
11
- export type LayerPopupConfigItem = {
12
- layer: ILayer | string;
13
- fields?: Array<LayerField | string>;
14
- title?: ElementType | ((feature: any) => ElementType);
15
- customContent?: ElementType | ((feature: any) => ElementType);
16
- };
17
- export interface ILayerPopupOption extends IPopupOption {
18
- config?: LayerPopupConfigItem[];
19
- items?: LayerPopupConfigItem[];
20
- trigger?: 'hover' | 'click' | 'touchend' | 'touchstart';
21
- }
22
- type LayerMapInfo = {
23
- onMouseMove?: (layer: ILayer, e: any) => void;
24
- onMouseOut?: (layer: ILayer, e: any) => void;
25
- onClick?: (layer: ILayer, e: any) => void;
26
- onSourceUpdate?: (layer: ILayer) => void;
27
- } & Partial<LayerPopupConfigItem>;
28
- export { LayerPopup };
29
- export default class LayerPopup extends Popup<ILayerPopupOption> {
30
- /**
31
- * 用于统计当前帧当中,layer 被点击的次数
32
- */
33
- protected layerClickCountByFrame: number;
34
- /**
35
- * 用于保存图层对应的事件回调以及配置信息
36
- * @protected
37
- */
38
- protected layerConfigMap: WeakMap<ILayer, LayerMapInfo>;
39
- /**
40
- * 当期正在展示的图层以及对应元素 id 的信息
41
- * @protected
42
- */
43
- protected displayFeatureInfo?: {
44
- layer: ILayer;
45
- featureId: number;
46
- };
47
- protected get layerConfigItems(): LayerPopupConfigItem[];
48
- /**
49
- * 根据环境获取实际的触发事件
50
- * 当 trigger 为 'click' 时,移动端使用 'touchend',PC 端使用 'click'
51
- * @protected
52
- */
53
- protected getActualTriggerEvent(): 'hover' | 'click' | 'touchend' | 'touchstart';
54
- addTo(scene: L7Container): this;
55
- remove(): this;
56
- setOptions(option: Partial<ILayerPopupOption>): this;
57
- protected getDefault(option: Partial<ILayerPopupOption>): ILayerPopupOption;
58
- /**
59
- * 绑定对应的图层事件
60
- * @protected
61
- */
62
- protected bindLayerEvent(): void;
63
- /**
64
- * 解绑对应的图层事件
65
- * @protected
66
- */
67
- protected unbindLayerEvent(): void;
68
- protected onLayerMouseMove(layer: ILayer, e: any): void;
69
- protected onLayerMouseOut(layer: ILayer): void;
70
- protected onLayerClick: (layer: ILayer, e: any) => void;
71
- protected onSceneClick: () => void;
72
- protected onSourceUpdate(): void;
73
- /**
74
- * 通过当前图层和对应选中的元素获取气泡展示的 HTML 内容
75
- * @param layer
76
- * @param e
77
- * @protected
78
- */
79
- protected getLayerInfoFrag(layer: ILayer, e: any): {
80
- title: DocumentFragment | undefined;
81
- content: DocumentFragment;
82
- };
83
- /**
84
- * 通过 Layer 配置访问到真实的 Layer 实例
85
- * @param configItem
86
- * @protected
87
- */
88
- protected getLayerByConfig(configItem: LayerPopupConfigItem): ILayer | undefined;
89
- /**
90
- * 判断当前展示的 Feature 是否和上一次查看的一致
91
- * @param layer
92
- * @param featureId
93
- * @protected
94
- */
95
- protected isSameFeature(layer: ILayer, featureId: number): boolean | undefined;
96
- protected setDisplayFeatureInfo(displayFeatureInfo?: {
97
- layer: ILayer;
98
- featureId: number;
99
- }): void;
100
- protected onLayerHide: () => void;
101
- /**
102
- * 覆盖 Popup 中的默认的 closeOnClick 行为
103
- */
104
- protected updateCloseOnClick: () => void;
105
- }