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