@antv/l7-component 2.9.24 → 2.9.26-alpha.0
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/package.json +5 -5
- package/es/control/BaseControl.d.ts +0 -27
- package/es/control/BaseControl.js +0 -134
- package/es/control/layer.d.ts +0 -38
- package/es/control/layer.js +0 -340
- package/es/control/logo.d.ts +0 -9
- package/es/control/logo.js +0 -57
- package/es/control/scale.d.ts +0 -24
- package/es/control/scale.js +0 -148
- package/es/control/zoom.d.ts +0 -24
- package/es/control/zoom.js +0 -119
- package/es/css/l7.css +0 -502
- package/es/images/layers.png +0 -0
- package/es/images/layers.svg +0 -1
- package/es/images/logo.png +0 -0
- package/es/index.d.ts +0 -11
- package/es/index.js +0 -53
- package/es/interface.d.ts +0 -37
- package/es/interface.js +0 -1
- package/es/marker-layer.d.ts +0 -50
- package/es/marker-layer.js +0 -331
- package/es/marker.d.ts +0 -47
- package/es/marker.js +0 -422
- package/es/popup.d.ts +0 -35
- package/es/popup.js +0 -300
- package/es/utils/anchor.d.ts +0 -22
- package/es/utils/anchor.js +0 -35
- package/lib/control/BaseControl.js +0 -110
- package/lib/control/layer.js +0 -269
- package/lib/control/logo.js +0 -54
- package/lib/control/scale.js +0 -119
- package/lib/control/zoom.js +0 -101
- package/lib/css/l7.css +0 -502
- package/lib/images/layers.png +0 -0
- package/lib/images/layers.svg +0 -1
- package/lib/images/logo.png +0 -0
- package/lib/index.js +0 -56
- package/lib/interface.js +0 -17
- package/lib/marker-layer.js +0 -238
- package/lib/marker.js +0 -302
- package/lib/popup.js +0 -216
- package/lib/utils/anchor.js +0 -63
package/lib/popup.js
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
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
|
|
23
|
-
});
|
|
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);
|
|
36
|
-
}
|
|
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
|
-
};
|
|
79
|
-
}
|
|
80
|
-
if (this.mapsService) {
|
|
81
|
-
this.mapsService.on("camerachange", this.update);
|
|
82
|
-
this.mapsService.on("viewchange", this.update);
|
|
83
|
-
}
|
|
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);
|
|
128
|
-
}
|
|
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";
|
|
135
|
-
}
|
|
136
|
-
this.closeButton.setAttribute("aria-label", "Close popup");
|
|
137
|
-
this.closeButton.innerHTML = "×";
|
|
138
|
-
this.closeButton.addEventListener("click", this.onClickClose);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
creatDom(tagName, className, container) {
|
|
142
|
-
const el = window.document.createElement(tagName);
|
|
143
|
-
if (className !== void 0) {
|
|
144
|
-
el.className = className;
|
|
145
|
-
}
|
|
146
|
-
if (container) {
|
|
147
|
-
container.appendChild(el);
|
|
148
|
-
}
|
|
149
|
-
return el;
|
|
150
|
-
}
|
|
151
|
-
removeDom(node) {
|
|
152
|
-
if (node.parentNode) {
|
|
153
|
-
node.parentNode.removeChild(node);
|
|
154
|
-
}
|
|
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();
|
|
170
|
-
}
|
|
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();
|
|
192
|
-
});
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
this.container.style.whiteSpace = "nowrap";
|
|
196
|
-
}
|
|
197
|
-
if (maxWidth && this.container.style.maxWidth !== maxWidth) {
|
|
198
|
-
this.container.style.maxWidth = maxWidth;
|
|
199
|
-
}
|
|
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
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
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/utils/anchor.ts
|
|
20
|
-
var anchor_exports = {};
|
|
21
|
-
__export(anchor_exports, {
|
|
22
|
-
anchorTranslate: () => anchorTranslate,
|
|
23
|
-
anchorType: () => anchorType,
|
|
24
|
-
applyAnchorClass: () => applyAnchorClass
|
|
25
|
-
});
|
|
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 || {});
|
|
38
|
-
var anchorTranslate = {
|
|
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%)"
|
|
48
|
-
};
|
|
49
|
-
function applyAnchorClass(element, anchor, prefix) {
|
|
50
|
-
const classList = element.classList;
|
|
51
|
-
for (const key in anchorTranslate) {
|
|
52
|
-
if (anchorTranslate.hasOwnProperty(key)) {
|
|
53
|
-
classList.remove(`l7-${prefix}-anchor-${key}`);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
classList.add(`l7-${prefix}-anchor-${anchor}`);
|
|
57
|
-
}
|
|
58
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
59
|
-
0 && (module.exports = {
|
|
60
|
-
anchorTranslate,
|
|
61
|
-
anchorType,
|
|
62
|
-
applyAnchorClass
|
|
63
|
-
});
|