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