@antv/l7-component 2.9.20 → 2.9.22
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/control/BaseControl.js +5 -26
- package/es/control/layer.js +13 -28
- package/es/control/logo.js +3 -4
- package/es/control/scale.js +6 -11
- package/es/control/zoom.js +3 -12
- package/es/css/l7.css +502 -0
- package/es/images/layers.png +0 -0
- package/es/images/layers.svg +1 -0
- package/es/images/logo.png +0 -0
- package/es/index.js +10 -10
- package/es/interface.js +1 -2
- package/es/marker-layer.js +27 -27
- package/es/marker.js +21 -27
- package/es/popup.js +16 -34
- package/es/utils/anchor.js +1 -2
- package/lib/control/BaseControl.js +100 -163
- package/lib/control/layer.js +248 -347
- package/lib/control/logo.js +52 -77
- package/lib/control/scale.js +112 -165
- package/lib/control/zoom.js +95 -143
- package/lib/css/l7.css +502 -0
- package/lib/images/layers.png +0 -0
- package/lib/images/layers.svg +1 -0
- package/lib/images/logo.png +0 -0
- package/lib/index.js +53 -135
- package/lib/interface.js +17 -2
- package/lib/marker-layer.js +224 -330
- package/lib/marker.js +271 -404
- package/lib/popup.js +201 -309
- package/lib/utils/anchor.js +54 -37
- package/package.json +9 -9
- package/es/control/BaseControl.js.map +0 -1
- package/es/control/layer.js.map +0 -1
- package/es/control/logo.js.map +0 -1
- package/es/control/scale.js.map +0 -1
- package/es/control/zoom.js.map +0 -1
- package/es/index.js.map +0 -1
- package/es/interface.js.map +0 -1
- package/es/marker-layer.js.map +0 -1
- package/es/marker.js.map +0 -1
- package/es/popup.js.map +0 -1
- package/es/utils/anchor.js.map +0 -1
- package/lib/control/BaseControl.js.map +0 -1
- package/lib/control/layer.js.map +0 -1
- package/lib/control/logo.js.map +0 -1
- package/lib/control/scale.js.map +0 -1
- package/lib/control/zoom.js.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/interface.js.map +0 -1
- package/lib/marker-layer.js.map +0 -1
- package/lib/marker.js.map +0 -1
- package/lib/popup.js.map +0 -1
- package/lib/utils/anchor.js.map +0 -1
package/lib/popup.js
CHANGED
|
@@ -1,324 +1,216 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/popup.ts
|
|
20
|
+
var popup_exports = {};
|
|
21
|
+
__export(popup_exports, {
|
|
22
|
+
default: () => Popup
|
|
7
23
|
});
|
|
8
|
-
exports
|
|
9
|
-
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
22
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
|
-
var _l7Core = require("@antv/l7-core");
|
|
25
|
-
|
|
26
|
-
var _l7Utils = require("@antv/l7-utils");
|
|
27
|
-
|
|
28
|
-
var _eventemitter = require("eventemitter3");
|
|
29
|
-
|
|
30
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
31
|
-
|
|
32
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
33
|
-
|
|
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
|
-
|
|
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
|
-
|
|
38
|
-
var Popup = function (_EventEmitter) {
|
|
39
|
-
(0, _inherits2.default)(Popup, _EventEmitter);
|
|
40
|
-
|
|
41
|
-
var _super = _createSuper(Popup);
|
|
42
|
-
|
|
43
|
-
function Popup(cfg) {
|
|
44
|
-
var _this;
|
|
45
|
-
|
|
46
|
-
(0, _classCallCheck2.default)(this, Popup);
|
|
47
|
-
_this = _super.call(this);
|
|
48
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "popupOption", void 0);
|
|
49
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "mapsService", void 0);
|
|
50
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "sceneSerive", void 0);
|
|
51
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "lngLat", void 0);
|
|
52
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "content", void 0);
|
|
53
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "closeButton", void 0);
|
|
54
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "timeoutInstance", void 0);
|
|
55
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "container", void 0);
|
|
56
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "tip", void 0);
|
|
57
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "scene", void 0);
|
|
58
|
-
_this.popupOption = _objectSpread(_objectSpread({}, _this.getdefault()), cfg);
|
|
59
|
-
(0, _l7Utils.bindAll)(['update', 'onClickClose', 'remove'], (0, _assertThisInitialized2.default)(_this));
|
|
60
|
-
return _this;
|
|
24
|
+
module.exports = __toCommonJS(popup_exports);
|
|
25
|
+
var import_l7_core = require("@antv/l7-core");
|
|
26
|
+
var import_l7_utils = require("@antv/l7-utils");
|
|
27
|
+
var import_eventemitter3 = require("eventemitter3");
|
|
28
|
+
var Popup = class extends import_eventemitter3.EventEmitter {
|
|
29
|
+
constructor(cfg) {
|
|
30
|
+
super();
|
|
31
|
+
this.popupOption = {
|
|
32
|
+
...this.getdefault(),
|
|
33
|
+
...cfg
|
|
34
|
+
};
|
|
35
|
+
(0, import_l7_utils.bindAll)(["update", "onClickClose", "remove"], this);
|
|
61
36
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
this.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
if (!child) {
|
|
106
|
-
break;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
frag.appendChild(child);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return this.setDOMContent(frag);
|
|
113
|
-
}
|
|
114
|
-
}, {
|
|
115
|
-
key: "setLnglat",
|
|
116
|
-
value: function setLnglat(lngLat) {
|
|
117
|
-
this.lngLat = lngLat;
|
|
118
|
-
|
|
119
|
-
if (Array.isArray(lngLat)) {
|
|
120
|
-
this.lngLat = {
|
|
121
|
-
lng: lngLat[0],
|
|
122
|
-
lat: lngLat[1]
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (this.mapsService) {
|
|
127
|
-
this.mapsService.on('camerachange', this.update);
|
|
128
|
-
this.mapsService.on('viewchange', this.update);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
this.update();
|
|
132
|
-
return this;
|
|
133
|
-
}
|
|
134
|
-
}, {
|
|
135
|
-
key: "getLnglat",
|
|
136
|
-
value: function getLnglat() {
|
|
137
|
-
return this.lngLat;
|
|
138
|
-
}
|
|
139
|
-
}, {
|
|
140
|
-
key: "setText",
|
|
141
|
-
value: function setText(text) {
|
|
142
|
-
return this.setDOMContent(window.document.createTextNode(text));
|
|
143
|
-
}
|
|
144
|
-
}, {
|
|
145
|
-
key: "setMaxWidth",
|
|
146
|
-
value: function setMaxWidth(maxWidth) {
|
|
147
|
-
this.popupOption.maxWidth = maxWidth;
|
|
148
|
-
this.update();
|
|
149
|
-
return this;
|
|
37
|
+
addTo(scene) {
|
|
38
|
+
this.mapsService = scene.get(import_l7_core.TYPES.IMapService);
|
|
39
|
+
this.sceneSerive = scene.get(import_l7_core.TYPES.ISceneService);
|
|
40
|
+
this.mapsService.on("camerachange", this.update);
|
|
41
|
+
this.mapsService.on("viewchange", this.update);
|
|
42
|
+
this.scene = scene;
|
|
43
|
+
this.update();
|
|
44
|
+
if (this.popupOption.closeOnClick) {
|
|
45
|
+
this.timeoutInstance = setTimeout(() => {
|
|
46
|
+
this.mapsService.on("click", this.onClickClose);
|
|
47
|
+
}, 30);
|
|
48
|
+
}
|
|
49
|
+
this.emit("open");
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
close() {
|
|
53
|
+
this.remove();
|
|
54
|
+
}
|
|
55
|
+
open() {
|
|
56
|
+
this.addTo(this.scene);
|
|
57
|
+
}
|
|
58
|
+
setHTML(html) {
|
|
59
|
+
const frag = window.document.createDocumentFragment();
|
|
60
|
+
const temp = window.document.createElement("body");
|
|
61
|
+
let child;
|
|
62
|
+
temp.innerHTML = html;
|
|
63
|
+
while (true) {
|
|
64
|
+
child = temp.firstChild;
|
|
65
|
+
if (!child) {
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
frag.appendChild(child);
|
|
69
|
+
}
|
|
70
|
+
return this.setDOMContent(frag);
|
|
71
|
+
}
|
|
72
|
+
setLnglat(lngLat) {
|
|
73
|
+
this.lngLat = lngLat;
|
|
74
|
+
if (Array.isArray(lngLat)) {
|
|
75
|
+
this.lngLat = {
|
|
76
|
+
lng: lngLat[0],
|
|
77
|
+
lat: lngLat[1]
|
|
78
|
+
};
|
|
150
79
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
this.createContent();
|
|
155
|
-
this.content.appendChild(htmlNode);
|
|
156
|
-
this.update();
|
|
157
|
-
return this;
|
|
80
|
+
if (this.mapsService) {
|
|
81
|
+
this.mapsService.on("camerachange", this.update);
|
|
82
|
+
this.mapsService.on("viewchange", this.update);
|
|
158
83
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
84
|
+
this.update();
|
|
85
|
+
return this;
|
|
86
|
+
}
|
|
87
|
+
getLnglat() {
|
|
88
|
+
return this.lngLat;
|
|
89
|
+
}
|
|
90
|
+
setText(text) {
|
|
91
|
+
return this.setDOMContent(window.document.createTextNode(text));
|
|
92
|
+
}
|
|
93
|
+
setMaxWidth(maxWidth) {
|
|
94
|
+
this.popupOption.maxWidth = maxWidth;
|
|
95
|
+
this.update();
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
setDOMContent(htmlNode) {
|
|
99
|
+
this.createContent();
|
|
100
|
+
this.content.appendChild(htmlNode);
|
|
101
|
+
this.update();
|
|
102
|
+
return this;
|
|
103
|
+
}
|
|
104
|
+
remove() {
|
|
105
|
+
if (this.content) {
|
|
106
|
+
this.removeDom(this.content);
|
|
107
|
+
}
|
|
108
|
+
if (this.container) {
|
|
109
|
+
this.removeDom(this.container);
|
|
110
|
+
delete this.container;
|
|
111
|
+
}
|
|
112
|
+
if (this.mapsService) {
|
|
113
|
+
this.mapsService.off("camerachange", this.update);
|
|
114
|
+
this.mapsService.off("viewchange", this.update);
|
|
115
|
+
this.mapsService.off("click", this.onClickClose);
|
|
116
|
+
delete this.mapsService;
|
|
117
|
+
}
|
|
118
|
+
clearTimeout(this.timeoutInstance);
|
|
119
|
+
this.emit("close");
|
|
120
|
+
return this;
|
|
121
|
+
}
|
|
122
|
+
isOpen() {
|
|
123
|
+
return !!this.mapsService;
|
|
124
|
+
}
|
|
125
|
+
createContent() {
|
|
126
|
+
if (this.content) {
|
|
127
|
+
import_l7_utils.DOM.remove(this.content);
|
|
186
128
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
if (this.
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
this.content = _l7Utils.DOM.create('div', 'l7-popup-content', this.container);
|
|
195
|
-
|
|
196
|
-
if (this.popupOption.closeButton) {
|
|
197
|
-
this.closeButton = _l7Utils.DOM.create('button', 'l7-popup-close-button', this.content);
|
|
198
|
-
|
|
199
|
-
if (this.popupOption.closeButtonOffsets) {
|
|
200
|
-
this.closeButton.style.right = this.popupOption.closeButtonOffsets[0] + 'px';
|
|
201
|
-
this.closeButton.style.top = this.popupOption.closeButtonOffsets[1] + 'px';
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
this.closeButton.setAttribute('aria-label', 'Close popup');
|
|
205
|
-
this.closeButton.innerHTML = '×';
|
|
206
|
-
this.closeButton.addEventListener('click', this.onClickClose);
|
|
129
|
+
this.content = import_l7_utils.DOM.create("div", "l7-popup-content", this.container);
|
|
130
|
+
if (this.popupOption.closeButton) {
|
|
131
|
+
this.closeButton = import_l7_utils.DOM.create("button", "l7-popup-close-button", this.content);
|
|
132
|
+
if (this.popupOption.closeButtonOffsets) {
|
|
133
|
+
this.closeButton.style.right = this.popupOption.closeButtonOffsets[0] + "px";
|
|
134
|
+
this.closeButton.style.top = this.popupOption.closeButtonOffsets[1] + "px";
|
|
207
135
|
}
|
|
136
|
+
this.closeButton.setAttribute("aria-label", "Close popup");
|
|
137
|
+
this.closeButton.innerHTML = "×";
|
|
138
|
+
this.closeButton.addEventListener("click", this.onClickClose);
|
|
208
139
|
}
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
if (className !== undefined) {
|
|
215
|
-
el.className = className;
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
if (container) {
|
|
219
|
-
container.appendChild(el);
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
return el;
|
|
140
|
+
}
|
|
141
|
+
creatDom(tagName, className, container) {
|
|
142
|
+
const el = window.document.createElement(tagName);
|
|
143
|
+
if (className !== void 0) {
|
|
144
|
+
el.className = className;
|
|
223
145
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
value: function removeDom(node) {
|
|
227
|
-
if (node.parentNode) {
|
|
228
|
-
node.parentNode.removeChild(node);
|
|
229
|
-
}
|
|
146
|
+
if (container) {
|
|
147
|
+
container.appendChild(el);
|
|
230
148
|
}
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
closeOnClick: true,
|
|
237
|
-
maxWidth: '240px',
|
|
238
|
-
offsets: [0, 0],
|
|
239
|
-
anchor: _l7Utils.anchorType.BOTTOM,
|
|
240
|
-
className: '',
|
|
241
|
-
stopPropagation: true
|
|
242
|
-
};
|
|
149
|
+
return el;
|
|
150
|
+
}
|
|
151
|
+
removeDom(node) {
|
|
152
|
+
if (node.parentNode) {
|
|
153
|
+
node.parentNode.removeChild(node);
|
|
243
154
|
}
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
155
|
+
}
|
|
156
|
+
getdefault() {
|
|
157
|
+
return {
|
|
158
|
+
closeButton: true,
|
|
159
|
+
closeOnClick: true,
|
|
160
|
+
maxWidth: "240px",
|
|
161
|
+
offsets: [0, 0],
|
|
162
|
+
anchor: import_l7_utils.anchorType.BOTTOM,
|
|
163
|
+
className: "",
|
|
164
|
+
stopPropagation: true
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
onClickClose(e) {
|
|
168
|
+
if (e.stopPropagation) {
|
|
169
|
+
e.stopPropagation();
|
|
252
170
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
if (className) {
|
|
276
|
-
className.split(' ').forEach(function (name) {
|
|
277
|
-
return _this3.container.classList.add(name);
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
var stopPropagation = this.popupOption.stopPropagation;
|
|
282
|
-
|
|
283
|
-
if (stopPropagation) {
|
|
284
|
-
['mousemove', 'mousedown', 'mouseup', 'click', 'dblclick'].forEach(function (type) {
|
|
285
|
-
_this3.container.addEventListener(type, function (e) {
|
|
286
|
-
e.stopPropagation();
|
|
287
|
-
});
|
|
171
|
+
this.remove();
|
|
172
|
+
}
|
|
173
|
+
update() {
|
|
174
|
+
const hasPosition = this.lngLat;
|
|
175
|
+
const { className, maxWidth, anchor } = this.popupOption;
|
|
176
|
+
if (!this.mapsService || !hasPosition || !this.content) {
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
const popupContainer = this.mapsService.getMarkerContainer();
|
|
180
|
+
if (!this.container && popupContainer) {
|
|
181
|
+
this.container = this.creatDom("div", "l7-popup", popupContainer);
|
|
182
|
+
this.tip = this.creatDom("div", "l7-popup-tip", this.container);
|
|
183
|
+
this.container.appendChild(this.content);
|
|
184
|
+
if (className) {
|
|
185
|
+
className.split(" ").forEach((name) => this.container.classList.add(name));
|
|
186
|
+
}
|
|
187
|
+
const { stopPropagation } = this.popupOption;
|
|
188
|
+
if (stopPropagation) {
|
|
189
|
+
["mousemove", "mousedown", "mouseup", "click", "dblclick"].forEach((type) => {
|
|
190
|
+
this.container.addEventListener(type, (e) => {
|
|
191
|
+
e.stopPropagation();
|
|
288
192
|
});
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
this.container.style.whiteSpace = 'nowrap';
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
if (maxWidth && this.container.style.maxWidth !== maxWidth) {
|
|
295
|
-
this.container.style.maxWidth = maxWidth;
|
|
193
|
+
});
|
|
296
194
|
}
|
|
297
|
-
|
|
298
|
-
this.updatePosition();
|
|
299
|
-
|
|
300
|
-
_l7Utils.DOM.setTransform(this.container, "".concat(_l7Utils.anchorTranslate[anchor]));
|
|
301
|
-
|
|
302
|
-
(0, _l7Utils.applyAnchorClass)(this.container, anchor, 'popup');
|
|
195
|
+
this.container.style.whiteSpace = "nowrap";
|
|
303
196
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
value: function updatePosition() {
|
|
307
|
-
if (!this.mapsService) {
|
|
308
|
-
return;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
var _this$lngLat = this.lngLat,
|
|
312
|
-
lng = _this$lngLat.lng,
|
|
313
|
-
lat = _this$lngLat.lat;
|
|
314
|
-
var offsets = this.popupOption.offsets;
|
|
315
|
-
var pos = this.mapsService.lngLatToContainer([lng, lat]);
|
|
316
|
-
this.container.style.left = pos.x + offsets[0] + 'px';
|
|
317
|
-
this.container.style.top = pos.y - offsets[1] + 'px';
|
|
197
|
+
if (maxWidth && this.container.style.maxWidth !== maxWidth) {
|
|
198
|
+
this.container.style.maxWidth = maxWidth;
|
|
318
199
|
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
200
|
+
this.updatePosition();
|
|
201
|
+
import_l7_utils.DOM.setTransform(this.container, `${import_l7_utils.anchorTranslate[anchor]}`);
|
|
202
|
+
(0, import_l7_utils.applyAnchorClass)(this.container, anchor, "popup");
|
|
203
|
+
}
|
|
204
|
+
updatePosition() {
|
|
205
|
+
if (!this.mapsService) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
const { lng, lat } = this.lngLat;
|
|
209
|
+
const { offsets } = this.popupOption;
|
|
210
|
+
const pos = this.mapsService.lngLatToContainer([lng, lat]);
|
|
211
|
+
this.container.style.left = pos.x + offsets[0] + "px";
|
|
212
|
+
this.container.style.top = pos.y - offsets[1] + "px";
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
216
|
+
0 && (module.exports = {});
|
package/lib/utils/anchor.js
CHANGED
|
@@ -1,46 +1,63 @@
|
|
|
1
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
2
18
|
|
|
3
|
-
|
|
4
|
-
|
|
19
|
+
// src/utils/anchor.ts
|
|
20
|
+
var anchor_exports = {};
|
|
21
|
+
__export(anchor_exports, {
|
|
22
|
+
anchorTranslate: () => anchorTranslate,
|
|
23
|
+
anchorType: () => anchorType,
|
|
24
|
+
applyAnchorClass: () => applyAnchorClass
|
|
5
25
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
anchorType["LEFT"] = "left";
|
|
19
|
-
anchorType["RIGHT"] = "right";
|
|
20
|
-
})(anchorType || (exports.anchorType = anchorType = {}));
|
|
21
|
-
|
|
26
|
+
module.exports = __toCommonJS(anchor_exports);
|
|
27
|
+
var anchorType = /* @__PURE__ */ ((anchorType2) => {
|
|
28
|
+
anchorType2["CENTER"] = "center";
|
|
29
|
+
anchorType2["TOP"] = "top";
|
|
30
|
+
anchorType2["TOP-LEFT"] = "top-left";
|
|
31
|
+
anchorType2["TOP-RIGHT"] = "top-right";
|
|
32
|
+
anchorType2["BOTTOM"] = "bottom";
|
|
33
|
+
anchorType2["BOTTOM-LEFT"] = "bottom-left";
|
|
34
|
+
anchorType2["LEFT"] = "left";
|
|
35
|
+
anchorType2["RIGHT"] = "right";
|
|
36
|
+
return anchorType2;
|
|
37
|
+
})(anchorType || {});
|
|
22
38
|
var anchorTranslate = {
|
|
23
|
-
center:
|
|
24
|
-
top:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
bottom:
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
left:
|
|
31
|
-
right:
|
|
39
|
+
center: "translate(-50%,-50%)",
|
|
40
|
+
top: "translate(-50%,0)",
|
|
41
|
+
"top-left": "translate(0,0)",
|
|
42
|
+
"top-right": "translate(-100%,0)",
|
|
43
|
+
bottom: "translate(-50%,-100%)",
|
|
44
|
+
"bottom-left": "translate(0,-100%)",
|
|
45
|
+
"bottom-right": "translate(-100%,-100%)",
|
|
46
|
+
left: "translate(0,-50%)",
|
|
47
|
+
right: "translate(-100%,-50%)"
|
|
32
48
|
};
|
|
33
|
-
exports.anchorTranslate = anchorTranslate;
|
|
34
|
-
|
|
35
49
|
function applyAnchorClass(element, anchor, prefix) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
for (var key in anchorTranslate) {
|
|
50
|
+
const classList = element.classList;
|
|
51
|
+
for (const key in anchorTranslate) {
|
|
39
52
|
if (anchorTranslate.hasOwnProperty(key)) {
|
|
40
|
-
classList.remove(
|
|
53
|
+
classList.remove(`l7-${prefix}-anchor-${key}`);
|
|
41
54
|
}
|
|
42
55
|
}
|
|
43
|
-
|
|
44
|
-
classList.add("l7-".concat(prefix, "-anchor-").concat(anchor));
|
|
56
|
+
classList.add(`l7-${prefix}-anchor-${anchor}`);
|
|
45
57
|
}
|
|
46
|
-
|
|
58
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
+
0 && (module.exports = {
|
|
60
|
+
anchorTranslate,
|
|
61
|
+
anchorType,
|
|
62
|
+
applyAnchorClass
|
|
63
|
+
});
|