@antv/l7-component 2.9.37-alpha.1 → 2.9.37-alpha.2

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