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