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