@antv/l7-component 2.9.26-alpha.0 → 2.9.26
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.d.ts +27 -0
- package/es/control/BaseControl.js +134 -0
- package/es/control/layer.d.ts +38 -0
- package/es/control/layer.js +340 -0
- package/es/control/logo.d.ts +9 -0
- package/es/control/logo.js +57 -0
- package/es/control/scale.d.ts +24 -0
- package/es/control/scale.js +148 -0
- package/es/control/zoom.d.ts +24 -0
- package/es/control/zoom.js +119 -0
- 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.d.ts +11 -0
- package/es/index.js +53 -0
- package/es/interface.d.ts +37 -0
- package/es/interface.js +1 -0
- package/es/marker-layer.d.ts +53 -0
- package/es/marker-layer.js +355 -0
- package/es/marker.d.ts +49 -0
- package/es/marker.js +432 -0
- package/es/popup.d.ts +35 -0
- package/es/popup.js +300 -0
- package/es/utils/anchor.d.ts +22 -0
- package/es/utils/anchor.js +35 -0
- package/lib/control/BaseControl.js +110 -0
- package/lib/control/layer.js +269 -0
- package/lib/control/logo.js +54 -0
- package/lib/control/scale.js +119 -0
- package/lib/control/zoom.js +101 -0
- 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 +56 -0
- package/lib/interface.js +17 -0
- package/lib/marker-layer.js +257 -0
- package/lib/marker.js +307 -0
- package/lib/popup.js +216 -0
- package/lib/utils/anchor.js +63 -0
- package/package.json +5 -5
package/lib/popup.js
ADDED
|
@@ -0,0 +1,216 @@
|
|
|
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 = {});
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@antv/l7-component",
|
|
3
|
-
"version": "2.9.26
|
|
3
|
+
"version": "2.9.26",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"author": "lzxue",
|
|
26
26
|
"license": "ISC",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@antv/l7-core": "2.9.26
|
|
29
|
-
"@antv/l7-utils": "2.9.26
|
|
28
|
+
"@antv/l7-core": "2.9.26",
|
|
29
|
+
"@antv/l7-utils": "2.9.26",
|
|
30
30
|
"@babel/runtime": "^7.7.7",
|
|
31
31
|
"eventemitter3": "^4.0.0",
|
|
32
32
|
"inversify": "^5.0.1",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"supercluster": "^7.0.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@antv/l7-test-utils": "2.9.26
|
|
38
|
+
"@antv/l7-test-utils": "2.9.26"
|
|
39
39
|
},
|
|
40
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "4e6f44c4ae44f7e9b9bbe627fd35406b3e7a63e1",
|
|
41
41
|
"publishConfig": {
|
|
42
42
|
"access": "public"
|
|
43
43
|
}
|