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