@antv/l7-component 2.18.2 → 2.18.3

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/es/assets/iconfont/iconfont.js +46 -0
  2. package/es/constants/index.d.ts +60 -0
  3. package/es/constants/index.js +60 -0
  4. package/es/control/baseControl/buttonControl.d.ts +59 -0
  5. package/es/control/baseControl/buttonControl.js +177 -0
  6. package/es/control/baseControl/control.d.ts +112 -0
  7. package/es/control/baseControl/control.js +302 -0
  8. package/es/control/baseControl/index.d.ts +4 -0
  9. package/es/control/baseControl/index.js +4 -0
  10. package/es/control/baseControl/popperControl.d.ts +26 -0
  11. package/es/control/baseControl/popperControl.js +120 -0
  12. package/es/control/baseControl/selectControl.d.ts +46 -0
  13. package/es/control/baseControl/selectControl.js +204 -0
  14. package/es/control/exportImage.d.ts +18 -0
  15. package/es/control/exportImage.js +159 -0
  16. package/es/control/fullscreen.d.ts +19 -0
  17. package/es/control/fullscreen.js +119 -0
  18. package/es/control/geoLocate.d.ts +16 -0
  19. package/es/control/geoLocate.js +107 -0
  20. package/es/control/layerSwitch.d.ts +19 -0
  21. package/es/control/layerSwitch.js +141 -0
  22. package/es/control/logo.d.ts +13 -0
  23. package/es/control/logo.js +75 -0
  24. package/es/control/mapTheme.d.ts +10 -0
  25. package/es/control/mapTheme.js +110 -0
  26. package/es/control/mouseLocation.d.ts +15 -0
  27. package/es/control/mouseLocation.js +83 -0
  28. package/es/control/scale.d.ts +34 -0
  29. package/es/control/scale.js +149 -0
  30. package/es/control/zoom.d.ts +38 -0
  31. package/es/control/zoom.js +132 -0
  32. package/es/css/button.less +70 -0
  33. package/es/css/control.less +71 -0
  34. package/es/css/index.css +594 -0
  35. package/es/css/index.less +12 -0
  36. package/es/css/l7.less +62 -0
  37. package/es/css/layerPopup.less +8 -0
  38. package/es/css/logo.less +18 -0
  39. package/es/css/mouseLocation.less +9 -0
  40. package/es/css/popper.less +64 -0
  41. package/es/css/popup.less +185 -0
  42. package/es/css/scale.less +34 -0
  43. package/es/css/select.less +86 -0
  44. package/es/css/variables.less +30 -0
  45. package/es/css/zoom.less +29 -0
  46. package/es/images/layers.png +0 -0
  47. package/es/images/layers.svg +1 -0
  48. package/es/images/logo.png +0 -0
  49. package/es/images/quanping.svg +12 -0
  50. package/es/index.d.ts +18 -0
  51. package/es/index.js +49 -0
  52. package/es/interface.d.ts +18 -0
  53. package/es/interface.js +1 -0
  54. package/es/marker-layer.d.ts +54 -0
  55. package/es/marker-layer.js +343 -0
  56. package/es/marker.d.ts +55 -0
  57. package/es/marker.js +410 -0
  58. package/es/popup/layerPopup.d.ts +86 -0
  59. package/es/popup/layerPopup.js +312 -0
  60. package/es/popup/popup.d.ts +139 -0
  61. package/es/popup/popup.js +567 -0
  62. package/es/utils/anchor.d.ts +22 -0
  63. package/es/utils/anchor.js +31 -0
  64. package/es/utils/icon.d.ts +1 -0
  65. package/es/utils/icon.js +9 -0
  66. package/es/utils/popper.d.ts +75 -0
  67. package/es/utils/popper.js +259 -0
  68. package/es/utils/screenfull.d.ts +2 -0
  69. package/es/utils/screenfull.js +128 -0
  70. package/lib/assets/iconfont/iconfont.js +48 -0
  71. package/lib/constants/index.js +68 -0
  72. package/lib/control/baseControl/buttonControl.js +183 -0
  73. package/lib/control/baseControl/control.js +314 -0
  74. package/lib/control/baseControl/index.js +39 -0
  75. package/lib/control/baseControl/popperControl.js +126 -0
  76. package/lib/control/baseControl/selectControl.js +210 -0
  77. package/lib/control/exportImage.js +165 -0
  78. package/lib/control/fullscreen.js +125 -0
  79. package/lib/control/geoLocate.js +113 -0
  80. package/lib/control/layerSwitch.js +147 -0
  81. package/lib/control/logo.js +81 -0
  82. package/lib/control/mapTheme.js +116 -0
  83. package/lib/control/mouseLocation.js +89 -0
  84. package/lib/control/scale.js +155 -0
  85. package/lib/control/zoom.js +138 -0
  86. package/lib/css/button.less +70 -0
  87. package/lib/css/control.less +71 -0
  88. package/lib/css/index.css +594 -0
  89. package/lib/css/index.less +12 -0
  90. package/lib/css/l7.less +62 -0
  91. package/lib/css/layerPopup.less +8 -0
  92. package/lib/css/logo.less +18 -0
  93. package/lib/css/mouseLocation.less +9 -0
  94. package/lib/css/popper.less +64 -0
  95. package/lib/css/popup.less +185 -0
  96. package/lib/css/scale.less +34 -0
  97. package/lib/css/select.less +86 -0
  98. package/lib/css/variables.less +30 -0
  99. package/lib/css/zoom.less +29 -0
  100. package/lib/images/layers.png +0 -0
  101. package/lib/images/layers.svg +1 -0
  102. package/lib/images/logo.png +0 -0
  103. package/lib/images/quanping.svg +12 -0
  104. package/lib/index.js +169 -0
  105. package/lib/interface.js +5 -0
  106. package/lib/marker-layer.js +349 -0
  107. package/lib/marker.js +417 -0
  108. package/lib/popup/layerPopup.js +317 -0
  109. package/lib/popup/popup.js +573 -0
  110. package/lib/utils/anchor.js +40 -0
  111. package/lib/utils/icon.js +16 -0
  112. package/lib/utils/popper.js +263 -0
  113. package/lib/utils/screenfull.js +136 -0
  114. package/package.json +6 -6
@@ -0,0 +1,573 @@
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 _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
10
+ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
11
+ var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
12
+ var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
13
+ var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
14
+ var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
15
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
16
+ var _l7Core = require("@antv/l7-core");
17
+ var _l7Utils = require("@antv/l7-utils");
18
+ var _eventemitter = require("eventemitter3");
19
+ var _icon = require("../utils/icon");
20
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
21
+ 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; } }
22
+ var Popup = /*#__PURE__*/function (_EventEmitter) {
23
+ (0, _inherits2.default)(Popup, _EventEmitter);
24
+ var _super = _createSuper(Popup);
25
+ function Popup(cfg) {
26
+ var _this;
27
+ (0, _classCallCheck2.default)(this, Popup);
28
+ _this = _super.call(this);
29
+ /**
30
+ * 配置
31
+ * @protected
32
+ */
33
+ /**
34
+ * 关闭按钮对应的 DOM
35
+ * @protected
36
+ */
37
+ /**
38
+ * Popup 的总容器 DOM,包含 content 和 tip
39
+ * @protected
40
+ */
41
+ /**
42
+ * popup 气泡容器
43
+ * @protected
44
+ */
45
+ /**
46
+ * popup 气泡标题
47
+ * @protected
48
+ */
49
+ /**
50
+ * popup 内容容器
51
+ * @protected
52
+ */
53
+ /**
54
+ * 气泡箭头对应的 DOM
55
+ * @protected
56
+ */
57
+ /**
58
+ * 当前是否展示
59
+ * @protected
60
+ */
61
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "isShow", true);
62
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onMouseMove", function (e) {
63
+ var _container$getBoundin;
64
+ var container = _this.mapsService.getMapContainer();
65
+ var _ref = (_container$getBoundin = container === null || container === void 0 ? void 0 : container.getBoundingClientRect()) !== null && _container$getBoundin !== void 0 ? _container$getBoundin : {},
66
+ _ref$left = _ref.left,
67
+ left = _ref$left === void 0 ? 0 : _ref$left,
68
+ _ref$top = _ref.top,
69
+ top = _ref$top === void 0 ? 0 : _ref$top;
70
+ _this.setPopupPosition(e.clientX - left, e.clientY - top);
71
+ });
72
+ /**
73
+ * 将经纬度转换成对应的像素偏移位置
74
+ * @protected
75
+ */
76
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "updateLngLatPosition", function () {
77
+ if (!_this.mapsService || _this.popupOption.followCursor) {
78
+ return;
79
+ }
80
+ var _this$lngLat = _this.lngLat,
81
+ lng = _this$lngLat.lng,
82
+ lat = _this$lngLat.lat;
83
+ var _this$mapsService$lng = _this.mapsService.lngLatToContainer([lng, lat]),
84
+ x = _this$mapsService$lng.x,
85
+ y = _this$mapsService$lng.y;
86
+ _this.setPopupPosition(x, y);
87
+ });
88
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onKeyDown", function (e) {
89
+ if (e.keyCode === 27) {
90
+ _this.remove();
91
+ }
92
+ });
93
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onCloseButtonClick", function (e) {
94
+ if (e.stopPropagation) {
95
+ e.stopPropagation();
96
+ }
97
+ _this.hide();
98
+ });
99
+ (0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "update", function () {
100
+ var hasPosition = !!_this.lngLat;
101
+ var _this$popupOption = _this.popupOption,
102
+ className = _this$popupOption.className,
103
+ style = _this$popupOption.style,
104
+ maxWidth = _this$popupOption.maxWidth,
105
+ anchor = _this$popupOption.anchor,
106
+ stopPropagation = _this$popupOption.stopPropagation;
107
+ if (!_this.mapsService || !hasPosition || !_this.content) {
108
+ return;
109
+ }
110
+ var popupContainer = _this.mapsService.getMarkerContainer();
111
+ // 如果当前没有创建 Popup 容器则创建
112
+ if (!_this.container && popupContainer) {
113
+ _this.container = _l7Utils.DOM.create('div', "l7-popup ".concat(className !== null && className !== void 0 ? className : '', " ").concat(!_this.isShow ? 'l7-popup-hide' : ''), popupContainer);
114
+ if (style) {
115
+ _this.container.setAttribute('style', style);
116
+ }
117
+ _this.tip = _l7Utils.DOM.create('div', 'l7-popup-tip', _this.container);
118
+ _this.container.appendChild(_this.content);
119
+
120
+ // 高德地图需要阻止事件冒泡 // 测试mapbox 地图不需要添加
121
+ if (stopPropagation) {
122
+ ['mousemove', 'mousedown', 'mouseup', 'click', 'dblclick'].forEach(function (type) {
123
+ _this.container.addEventListener(type, function (e) {
124
+ e.stopPropagation();
125
+ });
126
+ });
127
+ }
128
+ _this.container.style.whiteSpace = 'nowrap';
129
+ }
130
+ _this.updateLngLatPosition();
131
+ _l7Utils.DOM.setTransform(_this.container, "".concat(_l7Utils.anchorTranslate[anchor]));
132
+ (0, _l7Utils.applyAnchorClass)(_this.container, anchor, 'popup');
133
+ if (maxWidth) {
134
+ var _this$container$getBo = _this.container.getBoundingClientRect(),
135
+ width = _this$container$getBo.width;
136
+ if (width > parseFloat(maxWidth)) {
137
+ _this.container.style.width = maxWidth;
138
+ }
139
+ } else {
140
+ _this.container.style.removeProperty('width');
141
+ }
142
+ });
143
+ _this.popupOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, _this.getDefault(cfg !== null && cfg !== void 0 ? cfg : {})), cfg);
144
+ var lngLat = _this.popupOption.lngLat;
145
+ if (lngLat) {
146
+ _this.lngLat = lngLat;
147
+ }
148
+ return _this;
149
+ }
150
+ (0, _createClass2.default)(Popup, [{
151
+ key: "lngLat",
152
+ get: function get() {
153
+ var _this$popupOption$lng;
154
+ return (_this$popupOption$lng = this.popupOption.lngLat) !== null && _this$popupOption$lng !== void 0 ? _this$popupOption$lng : {
155
+ lng: 0,
156
+ lat: 0
157
+ };
158
+ },
159
+ set: function set(newLngLat) {
160
+ this.popupOption.lngLat = newLngLat;
161
+ }
162
+ }, {
163
+ key: "getIsShow",
164
+ value: function getIsShow() {
165
+ return this.isShow;
166
+ }
167
+ }, {
168
+ key: "addTo",
169
+ value: function addTo(scene) {
170
+ this.mapsService = scene.get(_l7Core.TYPES.IMapService);
171
+ this.sceneService = scene.get(_l7Core.TYPES.ISceneService);
172
+ this.layerService = scene.get(_l7Core.TYPES.ILayerService);
173
+ this.mapsService.on('camerachange', this.update);
174
+ this.mapsService.on('viewchange', this.update);
175
+ this.scene = scene;
176
+ this.update();
177
+ // 临时关闭
178
+ this.updateCloseOnClick();
179
+ this.updateCloseOnEsc();
180
+ this.updateFollowCursor();
181
+ var _this$popupOption2 = this.popupOption,
182
+ html = _this$popupOption2.html,
183
+ text = _this$popupOption2.text,
184
+ title = _this$popupOption2.title;
185
+ if (html) {
186
+ this.setHTML(html);
187
+ } else if (text) {
188
+ this.setText(text);
189
+ }
190
+ if (title) {
191
+ this.setTitle(title);
192
+ }
193
+ this.emit('open');
194
+ return this;
195
+ }
196
+
197
+ // 移除popup
198
+ }, {
199
+ key: "remove",
200
+ value: function remove() {
201
+ if (!(this !== null && this !== void 0 && this.isOpen())) {
202
+ return;
203
+ }
204
+ if (this.content) {
205
+ _l7Utils.DOM.remove(this.content);
206
+ }
207
+ if (this.container) {
208
+ _l7Utils.DOM.remove(this.container);
209
+ // @ts-ignore
210
+ delete this.container;
211
+ }
212
+ if (this.mapsService) {
213
+ // TODO: mapbox AMap 事件同步
214
+ this.mapsService.off('camerachange', this.update);
215
+ this.mapsService.off('viewchange', this.update);
216
+ this.updateCloseOnClick(true);
217
+ this.updateCloseOnEsc(true);
218
+ this.updateFollowCursor(true);
219
+ // @ts-ignore
220
+ delete this.mapsService;
221
+ }
222
+ this.emit('close');
223
+ return this;
224
+ }
225
+
226
+ /**
227
+ * 获取 option 配置
228
+ */
229
+ }, {
230
+ key: "getOptions",
231
+ value: function getOptions() {
232
+ return this.popupOption;
233
+ }
234
+ }, {
235
+ key: "setOptions",
236
+ value: function setOptions(option) {
237
+ this.show();
238
+ this.popupOption = (0, _objectSpread2.default)((0, _objectSpread2.default)({}, this.popupOption), option);
239
+ if (this.checkUpdateOption(option, ['html', 'text', 'title', 'closeButton', 'closeButtonOffsets', 'maxWidth', 'anchor', 'stopPropagation', 'className', 'style', 'lngLat', 'offsets'])) {
240
+ if (this.container) {
241
+ _l7Utils.DOM.remove(this.container);
242
+ // @ts-ignore
243
+ this.container = undefined;
244
+ }
245
+ if (this.popupOption.html) {
246
+ this.setHTML(this.popupOption.html);
247
+ } else if (this.popupOption.text) {
248
+ this.setText(this.popupOption.text);
249
+ }
250
+ if (this.popupOption.title) {
251
+ this.setTitle(this.popupOption.title);
252
+ }
253
+ }
254
+ if (this.checkUpdateOption(option, ['closeOnEsc'])) {
255
+ this.updateCloseOnEsc();
256
+ }
257
+ if (this.checkUpdateOption(option, ['closeOnClick'])) {
258
+ this.updateCloseOnClick();
259
+ }
260
+ if (this.checkUpdateOption(option, ['followCursor'])) {
261
+ this.updateFollowCursor();
262
+ }
263
+ if (this.checkUpdateOption(option, ['html']) && option.html) {
264
+ this.setHTML(option.html);
265
+ } else if (this.checkUpdateOption(option, ['text']) && option.text) {
266
+ this.setText(option.text);
267
+ }
268
+ if (this.checkUpdateOption(option, ['lngLat']) && option.lngLat) {
269
+ this.setLnglat(option.lngLat);
270
+ }
271
+ return this;
272
+ }
273
+ }, {
274
+ key: "open",
275
+ value: function open() {
276
+ this.addTo(this.scene);
277
+ return this;
278
+ }
279
+ }, {
280
+ key: "close",
281
+ value: function close() {
282
+ this.remove();
283
+ return this;
284
+ }
285
+ }, {
286
+ key: "show",
287
+ value: function show() {
288
+ if (this.isShow) {
289
+ return;
290
+ }
291
+ if (this.container) {
292
+ _l7Utils.DOM.removeClass(this.container, 'l7-popup-hide');
293
+ }
294
+ this.isShow = true;
295
+ this.emit('show');
296
+ return this;
297
+ }
298
+ }, {
299
+ key: "hide",
300
+ value: function hide() {
301
+ if (!this.isShow) {
302
+ return;
303
+ }
304
+ if (this.container) {
305
+ _l7Utils.DOM.addClass(this.container, 'l7-popup-hide');
306
+ }
307
+ this.isShow = false;
308
+ this.emit('hide');
309
+ return this;
310
+ }
311
+
312
+ /**
313
+ * 设置 HTML 内容
314
+ * @param html
315
+ */
316
+ }, {
317
+ key: "setHTML",
318
+ value: function setHTML(html) {
319
+ this.popupOption.html = html;
320
+ return this.setDOMContent(html);
321
+ }
322
+
323
+ /**
324
+ * 设置 Popup 展示文本
325
+ * @param text
326
+ */
327
+ }, {
328
+ key: "setText",
329
+ value: function setText(text) {
330
+ this.popupOption.text = text;
331
+ return this.setDOMContent(window.document.createTextNode(text));
332
+ }
333
+ }, {
334
+ key: "setTitle",
335
+ value: function setTitle(title) {
336
+ this.show();
337
+ this.popupOption.title = title;
338
+ if (title) {
339
+ if (!this.contentTitle) {
340
+ this.contentTitle = _l7Utils.DOM.create('div', 'l7-popup-content__title');
341
+ if (this.content.firstChild) {
342
+ this.content.insertBefore(this.contentTitle, this.content.firstChild);
343
+ } else {
344
+ this.content.append(this.contentTitle);
345
+ }
346
+ }
347
+ _l7Utils.DOM.clearChildren(this.contentTitle);
348
+ _l7Utils.DOM.appendElementType(this.contentTitle, title);
349
+ } else if (this.contentTitle) {
350
+ _l7Utils.DOM.remove(this.contentTitle);
351
+ this.contentTitle = undefined;
352
+ }
353
+ }
354
+
355
+ /**
356
+ * 将地图自动平移到气泡位置
357
+ */
358
+ }, {
359
+ key: "panToPopup",
360
+ value: function panToPopup() {
361
+ var _this$lngLat2 = this.lngLat,
362
+ lng = _this$lngLat2.lng,
363
+ lat = _this$lngLat2.lat;
364
+ if (this.popupOption.autoPan) {
365
+ this.mapsService.panTo([lng, lat]);
366
+ }
367
+ return this;
368
+ }
369
+ }, {
370
+ key: "setLngLat",
371
+ value: function setLngLat(lngLat) {
372
+ return this.setLnglat(lngLat);
373
+ }
374
+
375
+ /**
376
+ * 设置 Popup 所在经纬度
377
+ * @param lngLat
378
+ */
379
+ }, {
380
+ key: "setLnglat",
381
+ value: function setLnglat(lngLat) {
382
+ var _this2 = this;
383
+ this.show();
384
+ this.lngLat = lngLat;
385
+ if (Array.isArray(lngLat)) {
386
+ this.lngLat = {
387
+ lng: lngLat[0],
388
+ lat: lngLat[1]
389
+ };
390
+ }
391
+ if (this.mapsService) {
392
+ // 防止事件重复监听
393
+ this.mapsService.off('camerachange', this.update);
394
+ this.mapsService.off('viewchange', this.update);
395
+ this.mapsService.on('camerachange', this.update);
396
+ this.mapsService.on('viewchange', this.update);
397
+ }
398
+ this.update();
399
+ if (this.popupOption.autoPan) {
400
+ setTimeout(function () {
401
+ _this2.panToPopup();
402
+ }, 0);
403
+ }
404
+ return this;
405
+ }
406
+
407
+ /**
408
+ * 获取 Popup 所在经纬度
409
+ */
410
+ }, {
411
+ key: "getLnglat",
412
+ value: function getLnglat() {
413
+ return this.lngLat;
414
+ }
415
+
416
+ /**
417
+ * 设置 Popup 最大宽度
418
+ * @param maxWidth
419
+ */
420
+ }, {
421
+ key: "setMaxWidth",
422
+ value: function setMaxWidth(maxWidth) {
423
+ this.popupOption.maxWidth = maxWidth;
424
+ this.update();
425
+ return this;
426
+ }
427
+ }, {
428
+ key: "isOpen",
429
+ value: function isOpen() {
430
+ return !!this.mapsService;
431
+ }
432
+ }, {
433
+ key: "getDefault",
434
+ value:
435
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
436
+ function getDefault(option) {
437
+ // tslint:disable-next-line:no-object-literal-type-assertion
438
+ return {
439
+ closeButton: true,
440
+ closeOnClick: false,
441
+ maxWidth: '240px',
442
+ offsets: [0, 0],
443
+ anchor: _l7Utils.anchorType.BOTTOM,
444
+ stopPropagation: true,
445
+ autoPan: false,
446
+ autoClose: true,
447
+ closeOnEsc: false,
448
+ followCursor: false
449
+ };
450
+ }
451
+
452
+ /**
453
+ * 设置 Popup 内容 HTML
454
+ * @param element
455
+ */
456
+ }, {
457
+ key: "setDOMContent",
458
+ value: function setDOMContent(element) {
459
+ this.show();
460
+ this.createContent();
461
+ _l7Utils.DOM.appendElementType(this.contentPanel, element);
462
+ this.update();
463
+ return this;
464
+ }
465
+
466
+ /**
467
+ * 绑定地图点击事件触发销毁 Popup
468
+ * @protected
469
+ */
470
+ }, {
471
+ key: "updateCloseOnClick",
472
+ value: function updateCloseOnClick(onlyClear) {
473
+ var _this3 = this;
474
+ var mapsService = this.mapsService;
475
+ if (mapsService) {
476
+ mapsService === null || mapsService === void 0 ? void 0 : mapsService.off('click', this.onCloseButtonClick);
477
+ if (this.popupOption.closeOnClick && !onlyClear) {
478
+ requestAnimationFrame(function () {
479
+ mapsService === null || mapsService === void 0 ? void 0 : mapsService.on('click', _this3.onCloseButtonClick);
480
+ });
481
+ }
482
+ }
483
+ }
484
+ }, {
485
+ key: "updateCloseOnEsc",
486
+ value: function updateCloseOnEsc(onlyClear) {
487
+ window.removeEventListener('keydown', this.onKeyDown);
488
+ if (this.popupOption.closeOnEsc && !onlyClear) {
489
+ window.addEventListener('keydown', this.onKeyDown);
490
+ }
491
+ }
492
+ }, {
493
+ key: "updateFollowCursor",
494
+ value: function updateFollowCursor(onlyClear) {
495
+ var _this$mapsService;
496
+ var container = (_this$mapsService = this.mapsService) === null || _this$mapsService === void 0 ? void 0 : _this$mapsService.getContainer();
497
+ if (container) {
498
+ container === null || container === void 0 ? void 0 : container.removeEventListener('mousemove', this.onMouseMove);
499
+ if (this.popupOption.followCursor && !onlyClear) {
500
+ container === null || container === void 0 ? void 0 : container.addEventListener('mousemove', this.onMouseMove);
501
+ }
502
+ }
503
+ }
504
+ }, {
505
+ key: "createContent",
506
+ value:
507
+ /**
508
+ * 创建 Popup 内容容器的 DOM (在每次 setHTML 或 setText 时都会被调用)
509
+ * @protected
510
+ */
511
+ function createContent() {
512
+ var _this4 = this;
513
+ if (this.content) {
514
+ _l7Utils.DOM.remove(this.content);
515
+ }
516
+ this.contentTitle = undefined;
517
+ this.content = _l7Utils.DOM.create('div', 'l7-popup-content', this.container);
518
+ this.setTitle(this.popupOption.title);
519
+ if (this.popupOption.closeButton) {
520
+ var closeButton = (0, _icon.createL7Icon)('l7-icon-guanbi');
521
+ _l7Utils.DOM.addClass(closeButton, 'l7-popup-close-button');
522
+ this.content.appendChild(closeButton);
523
+ if (this.popupOption.closeButtonOffsets) {
524
+ // 关闭按钮的偏移
525
+ closeButton.style.right = this.popupOption.closeButtonOffsets[0] + 'px';
526
+ closeButton.style.top = this.popupOption.closeButtonOffsets[1] + 'px';
527
+ }
528
+
529
+ // this.closeButton.type = 'button';
530
+ closeButton.setAttribute('aria-label', 'Close popup');
531
+ closeButton.addEventListener('click', function () {
532
+ _this4.hide();
533
+ });
534
+ this.closeButton = closeButton;
535
+ } else {
536
+ this.closeButton = undefined;
537
+ }
538
+ this.contentPanel = _l7Utils.DOM.create('div', 'l7-popup-content__panel', this.content);
539
+ }
540
+ }, {
541
+ key: "setPopupPosition",
542
+ value:
543
+ /**
544
+ * 设置 Popup 相对于地图容器的 Position
545
+ * @param left
546
+ * @param top
547
+ * @protected
548
+ */
549
+ function setPopupPosition(left, top) {
550
+ if (this.container) {
551
+ var offsets = this.popupOption.offsets;
552
+ this.container.style.left = left + offsets[0] + 'px';
553
+ this.container.style.top = top - offsets[1] + 'px';
554
+ }
555
+ }
556
+
557
+ /**
558
+ * 检查当前传入 option 是否包含 keys 字段
559
+ * @param option
560
+ * @param keys
561
+ * @protected
562
+ */
563
+ }, {
564
+ key: "checkUpdateOption",
565
+ value: function checkUpdateOption(option, keys) {
566
+ return keys.some(function (key) {
567
+ return key in option;
568
+ });
569
+ }
570
+ }]);
571
+ return Popup;
572
+ }(_eventemitter.EventEmitter);
573
+ exports.default = exports.Popup = Popup;
@@ -0,0 +1,40 @@
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
+ var 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
+ exports.anchorType = anchorType;
20
+ var anchorTranslate = {
21
+ center: 'translate(-50%,-50%)',
22
+ top: 'translate(-50%,0)',
23
+ 'top-left': 'translate(0,0)',
24
+ 'top-right': 'translate(-100%,0)',
25
+ bottom: 'translate(-50%,-100%)',
26
+ 'bottom-left': 'translate(0,-100%)',
27
+ 'bottom-right': 'translate(-100%,-100%)',
28
+ left: 'translate(0,-50%)',
29
+ right: 'translate(-100%,-50%)'
30
+ };
31
+ exports.anchorTranslate = anchorTranslate;
32
+ function applyAnchorClass(element, anchor, prefix) {
33
+ var classList = element.classList;
34
+ for (var key in anchorTranslate) {
35
+ if (anchorTranslate.hasOwnProperty(key)) {
36
+ classList.remove("l7-".concat(prefix, "-anchor-").concat(key));
37
+ }
38
+ }
39
+ classList.add("l7-".concat(prefix, "-anchor-").concat(anchor));
40
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createL7Icon = void 0;
7
+ var createL7Icon = function createL7Icon(className) {
8
+ var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
9
+ svg.classList.add('l7-iconfont');
10
+ svg.setAttribute('aria-hidden', 'true');
11
+ var use = document.createElementNS('http://www.w3.org/2000/svg', 'use');
12
+ use.setAttributeNS('http://www.w3.org/1999/xlink', 'href', "#".concat(className));
13
+ svg.appendChild(use);
14
+ return svg;
15
+ };
16
+ exports.createL7Icon = createL7Icon;