@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
@@ -1,594 +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 = exports.Popup = 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
- var _icon = require("../utils/icon");
13
- class Popup extends _eventemitter.EventEmitter {
14
- get lngLat() {
15
- var _this$popupOption$lng;
16
- return (_this$popupOption$lng = this.popupOption.lngLat) !== null && _this$popupOption$lng !== void 0 ? _this$popupOption$lng : {
17
- lng: 0,
18
- lat: 0
19
- };
20
- }
21
- set lngLat(newLngLat) {
22
- this.popupOption.lngLat = newLngLat;
23
- }
24
- constructor(cfg) {
25
- super();
26
- /**
27
- * 配置
28
- * @protected
29
- */
30
- (0, _defineProperty2.default)(this, "popupOption", void 0);
31
- (0, _defineProperty2.default)(this, "mapsService", void 0);
32
- (0, _defineProperty2.default)(this, "sceneService", void 0);
33
- (0, _defineProperty2.default)(this, "layerService", void 0);
34
- (0, _defineProperty2.default)(this, "scene", void 0);
35
- /**
36
- * 关闭按钮对应的 DOM
37
- * @protected
38
- */
39
- (0, _defineProperty2.default)(this, "closeButton", void 0);
40
- /**
41
- * Popup 的总容器 DOM,包含 content 和 tip
42
- * @protected
43
- */
44
- (0, _defineProperty2.default)(this, "container", void 0);
45
- /**
46
- * popup 气泡容器
47
- * @protected
48
- */
49
- (0, _defineProperty2.default)(this, "content", void 0);
50
- /**
51
- * popup 气泡标题
52
- * @protected
53
- */
54
- (0, _defineProperty2.default)(this, "contentTitle", void 0);
55
- /**
56
- * popup 内容容器
57
- * @protected
58
- */
59
- (0, _defineProperty2.default)(this, "contentPanel", void 0);
60
- /**
61
- * 气泡箭头对应的 DOM
62
- * @protected
63
- */
64
- (0, _defineProperty2.default)(this, "tip", void 0);
65
- /**
66
- * 当前是否展示
67
- * @protected
68
- */
69
- (0, _defineProperty2.default)(this, "isShow", true);
70
- /**
71
- * RAF 节流 ID
72
- * @protected
73
- */
74
- (0, _defineProperty2.default)(this, "rafId", null);
75
- (0, _defineProperty2.default)(this, "onMouseMove", e => {
76
- var _container$getBoundin;
77
- const container = this.mapsService.getMapContainer();
78
- const {
79
- left = 0,
80
- top = 0
81
- } = (_container$getBoundin = container === null || container === void 0 ? void 0 : container.getBoundingClientRect()) !== null && _container$getBoundin !== void 0 ? _container$getBoundin : {};
82
- this.setPopupPosition(e.clientX - left, e.clientY - top);
83
- });
84
- /**
85
- * 将经纬度转换成对应的像素偏移位置
86
- * @protected
87
- */
88
- (0, _defineProperty2.default)(this, "updateLngLatPosition", () => {
89
- if (!this.mapsService || this.popupOption.followCursor) {
90
- return;
91
- }
92
- const {
93
- lng,
94
- lat
95
- } = this.lngLat;
96
- const {
97
- x,
98
- y
99
- } = this.mapsService.lngLatToContainer([lng, lat]);
100
- this.setPopupPosition(x, y);
101
- });
102
- //zoom时计算PopUp的位置并更新
103
- (0, _defineProperty2.default)(this, "updateLngLatPositionWhenZoom", ev => {
104
- if (!this.mapsService || this.popupOption.followCursor) {
105
- return;
106
- }
107
- const map = ev.map;
108
- const viewHalf = map.getSize();
109
- viewHalf.x = viewHalf.x / 2;
110
- viewHalf.y = viewHalf.y / 2;
111
- const center = ev.center;
112
- const zoom = ev.zoom;
113
- const projectedCenter = map.DE(this.lngLat, zoom, center);
114
- projectedCenter.x = Math.round(projectedCenter.x);
115
- projectedCenter.y = Math.round(projectedCenter.y);
116
- this.setPopupPosition(projectedCenter.x, projectedCenter.y, true);
117
- });
118
- (0, _defineProperty2.default)(this, "onKeyDown", e => {
119
- if (e.keyCode === 27) {
120
- this.remove();
121
- }
122
- });
123
- (0, _defineProperty2.default)(this, "onCloseButtonClick", e => {
124
- if (e.stopPropagation) {
125
- e.stopPropagation();
126
- }
127
- this.hide();
128
- });
129
- //更新位置 支持zoom时更新
130
- (0, _defineProperty2.default)(this, "updatePosition", (ev, zoom = true) => {
131
- const hasPosition = !!this.lngLat;
132
- const {
133
- className,
134
- style,
135
- maxWidth,
136
- anchor,
137
- stopPropagation
138
- } = this.popupOption;
139
- if (!this.mapsService || !hasPosition || !this.content) {
140
- return;
141
- }
142
- const popupContainer = this.mapsService.getMarkerContainer();
143
- // 如果当前没有创建 Popup 容器则创建
144
- if (!this.container && popupContainer) {
145
- this.container = _l7Utils.DOM.create('div', `l7-popup ${className !== null && className !== void 0 ? className : ''} ${!this.isShow ? 'l7-popup-hide' : ''}`, popupContainer);
146
- if (style) {
147
- this.container.setAttribute('style', style);
148
- }
149
- this.tip = _l7Utils.DOM.create('div', 'l7-popup-tip', this.container);
150
- this.container.appendChild(this.content);
151
-
152
- // 高德地图需要阻止事件冒泡 // 测试mapbox 地图不需要添加
153
- if (stopPropagation) {
154
- ['mousemove', 'mousedown', 'mouseup', 'click', 'dblclick'].forEach(type => {
155
- this.container.addEventListener(type, e => {
156
- e.stopPropagation();
157
- });
158
- });
159
- }
160
- this.container.style.whiteSpace = 'nowrap';
161
- }
162
- if (zoom) {
163
- this.updateLngLatPositionWhenZoom(ev);
164
- } else {
165
- this.updateLngLatPosition();
166
- }
167
- _l7Utils.DOM.setTransform(this.container, `${_l7Utils.anchorTranslate[anchor]}`);
168
- (0, _l7Utils.applyAnchorClass)(this.container, anchor, 'popup');
169
- if (maxWidth) {
170
- const {
171
- width
172
- } = this.container.getBoundingClientRect();
173
- if (width > parseFloat(maxWidth)) {
174
- this.container.style.width = maxWidth;
175
- }
176
- } else {
177
- this.container.style.removeProperty('width');
178
- }
179
- });
180
- (0, _defineProperty2.default)(this, "updateWhenZoom", ev => {
181
- this.updatePosition(ev, true);
182
- });
183
- (0, _defineProperty2.default)(this, "update", () => {
184
- // 使用 RAF 节流,避免高频事件导致的性能问题
185
- if (this.rafId !== null) {
186
- return;
187
- }
188
- this.rafId = requestAnimationFrame(() => {
189
- this.rafId = null;
190
- this.updatePosition(null, false);
191
- });
192
- });
193
- this.popupOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.getDefault(cfg !== null && cfg !== void 0 ? cfg : {})), cfg);
194
- const {
195
- lngLat
196
- } = this.popupOption;
197
- if (lngLat) {
198
- this.lngLat = lngLat;
199
- }
200
- }
201
- getIsShow() {
202
- return this.isShow;
203
- }
204
- addTo(scene) {
205
- this.mapsService = scene.mapService;
206
- this.sceneService = scene.sceneService;
207
- this.layerService = scene.layerService;
208
- //天地图仅监听zoomchange 不注册camerachane,对于平移,在mapsService中实现
209
- // this.mapsService.on('zoomchange', this.updateWhenZoom);
210
- this.mapsService.on('camerachange', this.update);
211
- this.mapsService.on('viewchange', this.update);
212
- this.scene = scene;
213
- this.update();
214
- // 临时关闭
215
- this.updateCloseOnClick();
216
- this.updateCloseOnEsc();
217
- this.updateFollowCursor();
218
- const {
219
- html,
220
- text,
221
- title
222
- } = this.popupOption;
223
- if (html) {
224
- this.setHTML(html);
225
- } else if (text) {
226
- this.setText(text);
227
- }
228
- if (title) {
229
- this.setTitle(title);
230
- }
231
- this.emit('open');
232
- return this;
233
- }
234
-
235
- // 移除popup
236
- remove() {
237
- if (!(this !== null && this !== void 0 && this.isOpen())) {
238
- return;
239
- }
240
-
241
- // 取消未执行的 RAF
242
- if (this.rafId !== null) {
243
- cancelAnimationFrame(this.rafId);
244
- this.rafId = null;
245
- }
246
- if (this.content) {
247
- _l7Utils.DOM.remove(this.content);
248
- }
249
- if (this.container) {
250
- _l7Utils.DOM.remove(this.container);
251
- // @ts-ignore
252
- delete this.container;
253
- }
254
- if (this.mapsService) {
255
- // TODO: mapbox AMap 事件同步
256
- this.mapsService.off('camerachange', this.update);
257
- this.mapsService.off('viewchange', this.update);
258
- //天地图的缩放事件
259
- // this.mapsService.off('zoomchange', this.updateWhenZoom);
260
- this.updateCloseOnClick(true);
261
- this.updateCloseOnEsc(true);
262
- this.updateFollowCursor(true);
263
- // @ts-ignore
264
- delete this.mapsService;
265
- }
266
- this.emit('close');
267
- return this;
268
- }
269
-
270
- /**
271
- * 获取 option 配置
272
- */
273
- getOptions() {
274
- return this.popupOption;
275
- }
276
- setOptions(option) {
277
- this.show();
278
- const {
279
- className: oldClassName
280
- } = this.popupOption;
281
- this.popupOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.popupOption), option);
282
- if (this.checkUpdateOption(option, ['html', 'text', 'title', 'closeButton', 'closeButtonOffsets', 'maxWidth', 'anchor', 'stopPropagation', 'lngLat', 'offsets'])) {
283
- if (this.container) {
284
- _l7Utils.DOM.remove(this.container);
285
- // @ts-ignore
286
- this.container = undefined;
287
- }
288
- if (this.popupOption.html) {
289
- this.setHTML(this.popupOption.html);
290
- } else if (this.popupOption.text) {
291
- this.setText(this.popupOption.text);
292
- }
293
- if (this.popupOption.title) {
294
- this.setTitle(this.popupOption.title);
295
- }
296
- }
297
- if (this.checkUpdateOption(option, ['closeOnEsc'])) {
298
- this.updateCloseOnEsc();
299
- }
300
- if (this.checkUpdateOption(option, ['closeOnClick'])) {
301
- this.updateCloseOnClick();
302
- }
303
- if (this.checkUpdateOption(option, ['followCursor'])) {
304
- this.updateFollowCursor();
305
- }
306
- if (this.checkUpdateOption(option, ['html']) && option.html) {
307
- this.setHTML(option.html);
308
- } else if (this.checkUpdateOption(option, ['text']) && option.text) {
309
- this.setText(option.text);
310
- }
311
- if (this.checkUpdateOption(option, ['className'])) {
312
- var _option$className;
313
- if (oldClassName) {
314
- this.container.classList.remove(oldClassName !== null && oldClassName !== void 0 ? oldClassName : '');
315
- }
316
- this.container.classList.add((_option$className = option.className) !== null && _option$className !== void 0 ? _option$className : '');
317
- }
318
- if (this.checkUpdateOption(option, ['style'])) {
319
- var _option$style;
320
- _l7Utils.DOM.addStyle(this.container, (_option$style = option.style) !== null && _option$style !== void 0 ? _option$style : '');
321
- }
322
- if (this.checkUpdateOption(option, ['lngLat']) && option.lngLat) {
323
- this.setLnglat(option.lngLat);
324
- }
325
- return this;
326
- }
327
- open() {
328
- this.addTo(this.scene);
329
- return this;
330
- }
331
- close() {
332
- this.remove();
333
- return this;
334
- }
335
- show() {
336
- if (this.isShow) {
337
- return;
338
- }
339
- if (this.container) {
340
- _l7Utils.DOM.removeClass(this.container, 'l7-popup-hide');
341
- }
342
- this.isShow = true;
343
- this.emit('show');
344
- return this;
345
- }
346
- hide() {
347
- if (!this.isShow) {
348
- return;
349
- }
350
- if (this.container) {
351
- _l7Utils.DOM.addClass(this.container, 'l7-popup-hide');
352
- }
353
- this.isShow = false;
354
- this.emit('hide');
355
- return this;
356
- }
357
-
358
- /**
359
- * 设置 HTML 内容
360
- * @param html
361
- */
362
- setHTML(html) {
363
- this.popupOption.html = html;
364
- return this.setDOMContent(html);
365
- }
366
-
367
- /**
368
- * 设置 Popup 展示文本
369
- * @param text
370
- */
371
- setText(text) {
372
- this.popupOption.text = text;
373
- return this.setDOMContent(window.document.createTextNode(text));
374
- }
375
- setTitle(title) {
376
- this.show();
377
- this.popupOption.title = title;
378
- if (title) {
379
- if (!this.contentTitle) {
380
- this.contentTitle = _l7Utils.DOM.create('div', 'l7-popup-content__title');
381
- if (this.content.firstChild) {
382
- this.content.insertBefore(this.contentTitle, this.content.firstChild);
383
- } else {
384
- this.content.append(this.contentTitle);
385
- }
386
- }
387
- _l7Utils.DOM.clearChildren(this.contentTitle);
388
- _l7Utils.DOM.appendElementType(this.contentTitle, title);
389
- } else if (this.contentTitle) {
390
- _l7Utils.DOM.remove(this.contentTitle);
391
- this.contentTitle = undefined;
392
- }
393
- }
394
-
395
- /**
396
- * 将地图自动平移到气泡位置
397
- */
398
- panToPopup() {
399
- const {
400
- lng,
401
- lat
402
- } = this.lngLat;
403
- if (this.popupOption.autoPan) {
404
- this.mapsService.panTo([lng, lat]);
405
- }
406
- return this;
407
- }
408
- setLngLat(lngLat) {
409
- return this.setLnglat(lngLat);
410
- }
411
-
412
- /**
413
- * 设置 Popup 所在经纬度
414
- * @param lngLat
415
- */
416
- setLnglat(lngLat) {
417
- this.show();
418
- this.lngLat = lngLat;
419
- if (Array.isArray(lngLat)) {
420
- this.lngLat = {
421
- lng: lngLat[0],
422
- lat: lngLat[1]
423
- };
424
- }
425
- if (this.mapsService) {
426
- // 防止事件重复监听
427
- // this.mapsService.off('zoonanim', this.updateWhenZoom);
428
- this.mapsService.off('camerachange', this.update);
429
- this.mapsService.off('viewchange', this.update);
430
-
431
- // this.mapsService.on('zoonanim', this.updateWhenZoom);
432
- this.mapsService.on('camerachange', this.update);
433
- this.mapsService.on('viewchange', this.update);
434
- }
435
- this.update();
436
- if (this.popupOption.autoPan) {
437
- setTimeout(() => {
438
- this.panToPopup();
439
- }, 0);
440
- }
441
- return this;
442
- }
443
-
444
- /**
445
- * 获取 Popup 所在经纬度
446
- */
447
- getLnglat() {
448
- return this.lngLat;
449
- }
450
-
451
- /**
452
- * 设置 Popup 最大宽度
453
- * @param maxWidth
454
- */
455
- setMaxWidth(maxWidth) {
456
- this.popupOption.maxWidth = maxWidth;
457
- this.update();
458
- return this;
459
- }
460
- isOpen() {
461
- return !!this.mapsService;
462
- }
463
- getDefault(option) {
464
- // tslint:disable-next-line:no-object-literal-type-assertion
465
- return {
466
- closeButton: true,
467
- closeOnClick: false,
468
- maxWidth: '240px',
469
- offsets: [0, 0],
470
- anchor: _l7Utils.anchorType.BOTTOM,
471
- stopPropagation: true,
472
- autoPan: false,
473
- autoClose: true,
474
- closeOnEsc: false,
475
- followCursor: false
476
- };
477
- }
478
-
479
- /**
480
- * 设置 Popup 内容 HTML
481
- * @param element
482
- */
483
- setDOMContent(element) {
484
- this.show();
485
- this.createContent();
486
- _l7Utils.DOM.appendElementType(this.contentPanel, element);
487
- this.update();
488
- return this;
489
- }
490
-
491
- /**
492
- * 绑定地图点击事件触发销毁 Popup
493
- * @protected
494
- */
495
- updateCloseOnClick(onlyClear) {
496
- const mapsService = this.mapsService;
497
- if (mapsService) {
498
- mapsService === null || mapsService === void 0 || mapsService.off('click', this.onCloseButtonClick);
499
- if (this.popupOption.closeOnClick && !onlyClear) {
500
- requestAnimationFrame(() => {
501
- mapsService === null || mapsService === void 0 || mapsService.on('click', this.onCloseButtonClick);
502
- });
503
- }
504
- }
505
- }
506
- updateCloseOnEsc(onlyClear) {
507
- window.removeEventListener('keydown', this.onKeyDown);
508
- if (this.popupOption.closeOnEsc && !onlyClear) {
509
- window.addEventListener('keydown', this.onKeyDown);
510
- }
511
- }
512
- updateFollowCursor(onlyClear) {
513
- var _this$mapsService;
514
- const container = (_this$mapsService = this.mapsService) === null || _this$mapsService === void 0 ? void 0 : _this$mapsService.getContainer();
515
- if (container) {
516
- container === null || container === void 0 || container.removeEventListener('mousemove', this.onMouseMove);
517
- if (this.popupOption.followCursor && !onlyClear) {
518
- container === null || container === void 0 || container.addEventListener('mousemove', this.onMouseMove);
519
- }
520
- }
521
- }
522
- /**
523
- * 创建 Popup 内容容器的 DOM (在每次 setHTML 或 setText 时都会被调用)
524
- * @protected
525
- */
526
- createContent() {
527
- if (this.content) {
528
- _l7Utils.DOM.remove(this.content);
529
- }
530
- this.contentTitle = undefined;
531
- this.content = _l7Utils.DOM.create('div', 'l7-popup-content', this.container);
532
- this.setTitle(this.popupOption.title);
533
- if (this.popupOption.closeButton) {
534
- const closeButton = (0, _icon.createL7Icon)('l7-icon-guanbi');
535
- _l7Utils.DOM.addClass(closeButton, 'l7-popup-close-button');
536
- this.content.appendChild(closeButton);
537
- if (this.popupOption.closeButtonOffsets) {
538
- // 关闭按钮的偏移
539
- closeButton.style.right = this.popupOption.closeButtonOffsets[0] + 'px';
540
- closeButton.style.top = this.popupOption.closeButtonOffsets[1] + 'px';
541
- }
542
-
543
- // this.closeButton.type = 'button';
544
- closeButton.setAttribute('aria-label', 'Close popup');
545
- closeButton.addEventListener('click', () => {
546
- this.hide();
547
- });
548
-
549
- // 防止点击 Popup 关闭按钮时,触发 Layer click 事件
550
- closeButton.addEventListener('pointerup', e => {
551
- e.stopPropagation();
552
- });
553
- closeButton.addEventListener('pointerdown', e => {
554
- e.stopPropagation();
555
- });
556
- this.closeButton = closeButton;
557
- } else {
558
- this.closeButton = undefined;
559
- }
560
- this.contentPanel = _l7Utils.DOM.create('div', 'l7-popup-content__panel', this.content);
561
- }
562
- /**
563
- * 设置 Popup 相对于地图容器的 Position
564
- * @param {Number} left
565
- * @param {Number} top
566
- * @param {Boolean} [useTransition=false] 是否使用过度效果
567
- * @protected
568
- */
569
- setPopupPosition(left, top, useTransition = false) {
570
- if (this.container) {
571
- const {
572
- offsets
573
- } = this.popupOption;
574
- this.container.style.left = left + offsets[0] + 'px';
575
- this.container.style.top = top - offsets[1] + 'px';
576
- if (useTransition) {
577
- this.container.style.transition = 'left 0.25s cubic-bezier(0,0,0.25,1), top 0.25s cubic-bezier(0,0,0.25,1)';
578
- } else {
579
- this.container.style.transition = '';
580
- }
581
- }
582
- }
583
-
584
- /**
585
- * 检查当前传入 option 是否包含 keys 字段
586
- * @param option
587
- * @param keys
588
- * @protected
589
- */
590
- checkUpdateOption(option, keys) {
591
- return keys.some(key => key in option);
592
- }
593
- }
594
- exports.default = exports.Popup = Popup;
@@ -1,22 +0,0 @@
1
- export declare enum anchorType {
2
- 'CENTER' = "center",
3
- 'TOP' = "top",
4
- 'TOP-LEFT' = "top-left",
5
- 'TOP-RIGHT' = "top-right",
6
- 'BOTTOM' = "bottom",
7
- 'BOTTOM-LEFT' = "bottom-left",
8
- 'LEFT' = "left",
9
- 'RIGHT' = "right"
10
- }
11
- export declare const anchorTranslate: {
12
- center: string;
13
- top: string;
14
- 'top-left': string;
15
- 'top-right': string;
16
- bottom: string;
17
- 'bottom-left': string;
18
- 'bottom-right': string;
19
- left: string;
20
- right: string;
21
- };
22
- export declare function applyAnchorClass(element: HTMLElement, anchor: string, prefix: string): void;
@@ -1,38 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.anchorType = exports.anchorTranslate = void 0;
7
- exports.applyAnchorClass = applyAnchorClass;
8
- let anchorType = exports.anchorType = /*#__PURE__*/function (anchorType) {
9
- anchorType["CENTER"] = "center";
10
- anchorType["TOP"] = "top";
11
- anchorType["TOP-LEFT"] = "top-left";
12
- anchorType["TOP-RIGHT"] = "top-right";
13
- anchorType["BOTTOM"] = "bottom";
14
- anchorType["BOTTOM-LEFT"] = "bottom-left";
15
- anchorType["LEFT"] = "left";
16
- anchorType["RIGHT"] = "right";
17
- return anchorType;
18
- }({});
19
- const anchorTranslate = exports.anchorTranslate = {
20
- center: 'translate(-50%,-50%)',
21
- top: 'translate(-50%,0)',
22
- 'top-left': 'translate(0,0)',
23
- 'top-right': 'translate(-100%,0)',
24
- bottom: 'translate(-50%,-100%)',
25
- 'bottom-left': 'translate(0,-100%)',
26
- 'bottom-right': 'translate(-100%,-100%)',
27
- left: 'translate(0,-50%)',
28
- right: 'translate(-100%,-50%)'
29
- };
30
- function applyAnchorClass(element, anchor, prefix) {
31
- const classList = element.classList;
32
- for (const key in anchorTranslate) {
33
- if (anchorTranslate.hasOwnProperty(key)) {
34
- classList.remove(`l7-${prefix}-anchor-${key}`);
35
- }
36
- }
37
- classList.add(`l7-${prefix}-anchor-${anchor}`);
38
- }
@@ -1,42 +0,0 @@
1
- import type { IMapService } from '@antv/l7-core';
2
- type EventHandler = (...args: any[]) => void;
3
- /**
4
- * 事件管理器,用于统一管理事件绑定和解绑
5
- * 解决组件销毁时事件未正确清理导致的内存泄漏问题
6
- */
7
- export declare class EventManager {
8
- private bindings;
9
- /**
10
- * 绑定事件
11
- * @param target 事件目标对象
12
- * @param event 事件名称
13
- * @param handler 事件处理函数
14
- */
15
- on(target: IMapService, event: string, handler: EventHandler): this;
16
- on(target: HTMLElement, event: string, handler: EventHandler): this;
17
- on(target: Window, event: string, handler: EventHandler): this;
18
- on(target: Document, event: string, handler: EventHandler): this;
19
- /**
20
- * 解绑指定事件
21
- * @param target 事件目标对象
22
- * @param event 事件名称
23
- * @param handler 事件处理函数
24
- */
25
- off(target: IMapService, event: string, handler: EventHandler): this;
26
- off(target: HTMLElement, event: string, handler: EventHandler): this;
27
- off(target: Window, event: string, handler: EventHandler): this;
28
- off(target: Document, event: string, handler: EventHandler): this;
29
- /**
30
- * 清除所有绑定的事件
31
- */
32
- clear(): void;
33
- /**
34
- * 获取当前绑定的事件数量
35
- */
36
- size(): number;
37
- /**
38
- * 判断目标是否为 MapService
39
- */
40
- private isMapService;
41
- }
42
- export default EventManager;