@antv/l7-component 2.9.32-alpha.2 → 2.9.32-alpha.4
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 +53 -0
- package/es/constants/index.d.ts +60 -0
- package/es/constants/index.js +60 -0
- package/es/control/baseControl/buttonControl.d.ts +59 -0
- package/es/control/baseControl/buttonControl.js +191 -0
- package/es/control/baseControl/control.d.ts +107 -0
- package/es/control/baseControl/control.js +288 -0
- package/es/control/baseControl/index.d.ts +4 -0
- package/es/control/baseControl/index.js +4 -0
- package/es/control/baseControl/popperControl.d.ts +26 -0
- package/es/control/baseControl/popperControl.js +131 -0
- package/es/control/baseControl/selectControl.d.ts +46 -0
- package/es/control/baseControl/selectControl.js +227 -0
- package/es/control/exportImage.d.ts +18 -0
- package/es/control/exportImage.js +163 -0
- package/es/control/fullscreen.d.ts +19 -0
- package/es/control/fullscreen.js +151 -0
- package/es/control/geoLocate.d.ts +16 -0
- package/es/control/geoLocate.js +139 -0
- package/es/control/layerControl.d.ts +21 -0
- package/es/control/layerControl.js +172 -0
- package/es/control/logo.d.ts +13 -0
- package/es/control/logo.js +87 -0
- package/es/control/mapTheme.d.ts +10 -0
- package/es/control/mapTheme.js +135 -0
- package/es/control/mouseLocation.d.ts +15 -0
- package/es/control/mouseLocation.js +104 -0
- package/es/control/scale.d.ts +34 -0
- package/es/control/scale.js +172 -0
- package/es/control/zoom.d.ts +34 -0
- package/es/control/zoom.js +146 -0
- package/es/css/button.less +70 -0
- package/es/css/control.less +71 -0
- package/es/css/index.css +567 -0
- package/es/css/index.less +12 -0
- package/es/css/l7.less +60 -0
- package/es/css/layerPopup.less +8 -0
- package/es/css/logo.less +18 -0
- package/es/css/mouseLocation.less +9 -0
- package/es/css/popper.less +64 -0
- package/es/css/popup.less +169 -0
- package/es/css/scale.less +34 -0
- package/es/css/select.less +86 -0
- package/es/css/variables.less +28 -0
- package/es/css/zoom.less +21 -0
- package/es/images/layers.png +0 -0
- package/es/images/layers.svg +1 -0
- package/es/images/logo.png +0 -0
- package/es/images/quanping.svg +12 -0
- package/es/index.d.ts +18 -0
- package/es/index.js +59 -0
- package/es/interface.d.ts +18 -0
- package/es/interface.js +1 -0
- package/es/marker-layer.d.ts +53 -0
- package/es/marker-layer.js +363 -0
- package/es/marker.d.ts +49 -0
- package/es/marker.js +434 -0
- package/es/popup/layerPopup.d.ts +78 -0
- package/es/popup/layerPopup.js +308 -0
- package/es/popup/popup.d.ts +147 -0
- package/es/popup/popup.js +636 -0
- package/es/utils/anchor.d.ts +22 -0
- package/es/utils/anchor.js +35 -0
- package/es/utils/icon.d.ts +1 -0
- package/es/utils/icon.js +9 -0
- package/es/utils/popper.d.ts +75 -0
- package/es/utils/popper.js +286 -0
- package/es/utils/screenfull.d.ts +2 -0
- package/es/utils/screenfull.js +157 -0
- package/lib/assets/iconfont/iconfont.js +39 -0
- package/lib/constants/index.js +90 -0
- package/lib/control/baseControl/buttonControl.js +118 -0
- package/lib/control/baseControl/control.js +172 -0
- package/lib/control/baseControl/index.js +22 -0
- package/lib/control/baseControl/popperControl.js +108 -0
- package/lib/control/baseControl/selectControl.js +153 -0
- package/lib/control/exportImage.js +83 -0
- package/lib/control/fullscreen.js +109 -0
- package/lib/control/geoLocate.js +78 -0
- package/lib/control/layerControl.js +136 -0
- package/lib/control/logo.js +74 -0
- package/lib/control/mapTheme.js +92 -0
- package/lib/control/mouseLocation.js +79 -0
- package/lib/control/scale.js +136 -0
- package/lib/control/zoom.js +119 -0
- package/lib/css/button.less +70 -0
- package/lib/css/control.less +71 -0
- package/lib/css/index.css +567 -0
- package/lib/css/index.less +12 -0
- package/lib/css/l7.less +60 -0
- package/lib/css/layerPopup.less +8 -0
- package/lib/css/logo.less +18 -0
- package/lib/css/mouseLocation.less +9 -0
- package/lib/css/popper.less +64 -0
- package/lib/css/popup.less +169 -0
- package/lib/css/scale.less +34 -0
- package/lib/css/select.less +86 -0
- package/lib/css/variables.less +28 -0
- package/lib/css/zoom.less +21 -0
- package/lib/images/layers.png +0 -0
- package/lib/images/layers.svg +1 -0
- package/lib/images/logo.png +0 -0
- package/lib/images/quanping.svg +12 -0
- package/lib/index.js +51 -0
- package/lib/interface.js +17 -0
- package/lib/marker-layer.js +263 -0
- package/lib/marker.js +307 -0
- package/lib/popup/layerPopup.js +200 -0
- package/lib/popup/popup.js +388 -0
- package/lib/utils/anchor.js +63 -0
- package/lib/utils/icon.js +37 -0
- package/lib/utils/popper.js +209 -0
- package/lib/utils/screenfull.js +160 -0
- package/package.json +5 -5
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// src/marker-layer.ts
|
|
23
|
+
var marker_layer_exports = {};
|
|
24
|
+
__export(marker_layer_exports, {
|
|
25
|
+
default: () => MarkerLayer
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(marker_layer_exports);
|
|
28
|
+
var import_l7_core = require("@antv/l7-core");
|
|
29
|
+
var import_l7_utils = require("@antv/l7-utils");
|
|
30
|
+
var import_eventemitter3 = require("eventemitter3");
|
|
31
|
+
var import_lodash = require("lodash");
|
|
32
|
+
var import_supercluster = __toESM(require("supercluster/dist/supercluster"));
|
|
33
|
+
var import_marker = __toESM(require("./marker"));
|
|
34
|
+
var MarkerLayer = class extends import_eventemitter3.EventEmitter {
|
|
35
|
+
constructor(option) {
|
|
36
|
+
var _a;
|
|
37
|
+
super();
|
|
38
|
+
this.markers = [];
|
|
39
|
+
this.points = [];
|
|
40
|
+
this.clusterMarkers = [];
|
|
41
|
+
this.markerLayerOption = (0, import_lodash.merge)(this.getDefault(), option);
|
|
42
|
+
(0, import_l7_utils.bindAll)(["update"], this);
|
|
43
|
+
this.zoom = ((_a = this.markerLayerOption.clusterOption) == null ? void 0 : _a.zoom) || -99;
|
|
44
|
+
}
|
|
45
|
+
getDefault() {
|
|
46
|
+
return {
|
|
47
|
+
cluster: false,
|
|
48
|
+
clusterOption: {
|
|
49
|
+
radius: 80,
|
|
50
|
+
maxZoom: 20,
|
|
51
|
+
minZoom: 0,
|
|
52
|
+
zoom: -99,
|
|
53
|
+
style: {},
|
|
54
|
+
className: ""
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
addTo(scene) {
|
|
59
|
+
this.scene = scene;
|
|
60
|
+
this.mapsService = scene.get(import_l7_core.TYPES.IMapService);
|
|
61
|
+
if (this.markerLayerOption.cluster) {
|
|
62
|
+
this.initCluster();
|
|
63
|
+
this.update();
|
|
64
|
+
this.mapsService.on("camerachange", this.update);
|
|
65
|
+
this.mapsService.on("viewchange", this.update);
|
|
66
|
+
}
|
|
67
|
+
this.mapsService.on("camerachange", this.setContainerSize.bind(this));
|
|
68
|
+
this.mapsService.on("viewchange", this.setContainerSize.bind(this));
|
|
69
|
+
this.addMarkers();
|
|
70
|
+
return this;
|
|
71
|
+
}
|
|
72
|
+
setContainerSize() {
|
|
73
|
+
if (!this.mapsService)
|
|
74
|
+
return;
|
|
75
|
+
const container = this.mapsService.getContainer();
|
|
76
|
+
this.containerSize = {
|
|
77
|
+
containerWidth: (container == null ? void 0 : container.scrollWidth) || 0,
|
|
78
|
+
containerHeight: (container == null ? void 0 : container.scrollHeight) || 0,
|
|
79
|
+
bounds: this.mapsService.getBounds()
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
getContainerSize() {
|
|
83
|
+
return this.containerSize;
|
|
84
|
+
}
|
|
85
|
+
addMarker(marker) {
|
|
86
|
+
const cluster = this.markerLayerOption.cluster;
|
|
87
|
+
marker.getMarkerLayerContainerSize = this.getContainerSize.bind(this);
|
|
88
|
+
if (cluster) {
|
|
89
|
+
this.addPoint(marker, this.markers.length);
|
|
90
|
+
if (this.mapsService) {
|
|
91
|
+
const zoom = this.mapsService.getZoom();
|
|
92
|
+
const bbox = this.mapsService.getBounds();
|
|
93
|
+
this.bbox = (0, import_l7_utils.padBounds)(bbox, 0.5);
|
|
94
|
+
this.zoom = Math.floor(zoom);
|
|
95
|
+
this.getClusterMarker(this.bbox, this.zoom);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
this.markers.push(marker);
|
|
99
|
+
}
|
|
100
|
+
removeMarker(marker) {
|
|
101
|
+
this.markers.indexOf(marker);
|
|
102
|
+
const markerIndex = this.markers.indexOf(marker);
|
|
103
|
+
if (markerIndex > -1) {
|
|
104
|
+
this.markers.splice(markerIndex, 1);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
hide() {
|
|
108
|
+
this.markers.map((m) => {
|
|
109
|
+
m.getElement().style.opacity = "0";
|
|
110
|
+
});
|
|
111
|
+
this.clusterMarkers.map((m) => {
|
|
112
|
+
m.getElement().style.opacity = "0";
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
show() {
|
|
116
|
+
this.markers.map((m) => {
|
|
117
|
+
m.getElement().style.opacity = "1";
|
|
118
|
+
});
|
|
119
|
+
this.clusterMarkers.map((m) => {
|
|
120
|
+
m.getElement().style.opacity = "1";
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
getMarkers() {
|
|
124
|
+
const cluster = this.markerLayerOption.cluster;
|
|
125
|
+
return cluster ? this.clusterMarkers : this.markers;
|
|
126
|
+
}
|
|
127
|
+
addMarkers() {
|
|
128
|
+
this.getMarkers().forEach((marker) => {
|
|
129
|
+
marker.addTo(this.scene);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
clear() {
|
|
133
|
+
this.markers.forEach((marker) => {
|
|
134
|
+
marker.remove();
|
|
135
|
+
});
|
|
136
|
+
this.clusterMarkers.forEach((clusterMarker) => {
|
|
137
|
+
clusterMarker.remove();
|
|
138
|
+
});
|
|
139
|
+
this.markers = [];
|
|
140
|
+
this.points = [];
|
|
141
|
+
this.clusterMarkers = [];
|
|
142
|
+
}
|
|
143
|
+
destroy() {
|
|
144
|
+
this.clear();
|
|
145
|
+
this.removeAllListeners();
|
|
146
|
+
this.mapsService.off("camerachange", this.update);
|
|
147
|
+
this.mapsService.off("viewchange", this.update);
|
|
148
|
+
this.mapsService.off("camerachange", this.setContainerSize.bind(this));
|
|
149
|
+
this.mapsService.off("viewchange", this.setContainerSize.bind(this));
|
|
150
|
+
}
|
|
151
|
+
addPoint(marker, id) {
|
|
152
|
+
const { lng, lat } = marker.getLnglat();
|
|
153
|
+
const feature = {
|
|
154
|
+
geometry: {
|
|
155
|
+
type: "Point",
|
|
156
|
+
coordinates: [lng, lat]
|
|
157
|
+
},
|
|
158
|
+
properties: {
|
|
159
|
+
...marker.getExtData(),
|
|
160
|
+
marker_id: id
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
this.points.push(feature);
|
|
164
|
+
if (this.clusterIndex) {
|
|
165
|
+
this.clusterIndex.load(this.points);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
initCluster() {
|
|
169
|
+
if (!this.markerLayerOption.cluster) {
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
const {
|
|
173
|
+
radius,
|
|
174
|
+
minZoom = 0,
|
|
175
|
+
maxZoom
|
|
176
|
+
} = this.markerLayerOption.clusterOption;
|
|
177
|
+
this.clusterIndex = new import_supercluster.default({
|
|
178
|
+
radius,
|
|
179
|
+
minZoom,
|
|
180
|
+
maxZoom
|
|
181
|
+
});
|
|
182
|
+
this.clusterIndex.load(this.points);
|
|
183
|
+
}
|
|
184
|
+
getClusterMarker(viewBounds, zoom) {
|
|
185
|
+
const viewBBox = viewBounds[0].concat(viewBounds[1]);
|
|
186
|
+
const clusterPoint = this.clusterIndex.getClusters(viewBBox, zoom);
|
|
187
|
+
this.clusterMarkers.forEach((marker) => {
|
|
188
|
+
marker.remove();
|
|
189
|
+
});
|
|
190
|
+
this.clusterMarkers = [];
|
|
191
|
+
clusterPoint.forEach((feature) => {
|
|
192
|
+
var _a, _b;
|
|
193
|
+
const { field, method } = this.markerLayerOption.clusterOption;
|
|
194
|
+
if ((_a = feature.properties) == null ? void 0 : _a.cluster_id) {
|
|
195
|
+
const clusterData = this.getLeaves((_b = feature.properties) == null ? void 0 : _b.cluster_id);
|
|
196
|
+
feature.properties.clusterData = clusterData;
|
|
197
|
+
if (field && method) {
|
|
198
|
+
const columnData = clusterData == null ? void 0 : clusterData.map((item) => {
|
|
199
|
+
const data = {
|
|
200
|
+
[field]: item.properties[field]
|
|
201
|
+
};
|
|
202
|
+
return data;
|
|
203
|
+
});
|
|
204
|
+
const column = import_l7_utils.Satistics.getColumn(columnData, field);
|
|
205
|
+
const stat = import_l7_utils.Satistics.getSatByColumn(method, column);
|
|
206
|
+
const fieldName = "point_" + method;
|
|
207
|
+
feature.properties[fieldName] = stat.toFixed(2);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
const marker = this.clusterMarker(feature);
|
|
211
|
+
this.clusterMarkers.push(marker);
|
|
212
|
+
marker.addTo(this.scene);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
getLeaves(clusterId, limit = Infinity, offset = 0) {
|
|
216
|
+
if (!clusterId) {
|
|
217
|
+
return null;
|
|
218
|
+
}
|
|
219
|
+
return this.clusterIndex.getLeaves(clusterId, limit, offset);
|
|
220
|
+
}
|
|
221
|
+
clusterMarker(feature) {
|
|
222
|
+
const clusterOption = this.markerLayerOption.clusterOption;
|
|
223
|
+
const {
|
|
224
|
+
element = this.generateElement.bind(this)
|
|
225
|
+
} = clusterOption;
|
|
226
|
+
const marker = new import_marker.default({
|
|
227
|
+
element: element(feature)
|
|
228
|
+
}).setLnglat({
|
|
229
|
+
lng: feature.geometry.coordinates[0],
|
|
230
|
+
lat: feature.geometry.coordinates[1]
|
|
231
|
+
});
|
|
232
|
+
return marker;
|
|
233
|
+
}
|
|
234
|
+
normalMarker(feature) {
|
|
235
|
+
const marker_id = feature.properties.marker_id;
|
|
236
|
+
return this.markers[marker_id];
|
|
237
|
+
}
|
|
238
|
+
update() {
|
|
239
|
+
if (!this.mapsService)
|
|
240
|
+
return;
|
|
241
|
+
if (this.markers.length === 0)
|
|
242
|
+
return;
|
|
243
|
+
const zoom = this.mapsService.getZoom();
|
|
244
|
+
const bbox = this.mapsService.getBounds();
|
|
245
|
+
if (!this.bbox || Math.abs(zoom - this.zoom) >= 1 || !(0, import_l7_utils.boundsContains)(this.bbox, bbox)) {
|
|
246
|
+
this.bbox = (0, import_l7_utils.padBounds)(bbox, 0.5);
|
|
247
|
+
this.zoom = Math.floor(zoom);
|
|
248
|
+
this.getClusterMarker(this.bbox, this.zoom);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
generateElement(feature) {
|
|
252
|
+
const el = import_l7_utils.DOM.create("div", "l7-marker-cluster");
|
|
253
|
+
const label = import_l7_utils.DOM.create("div", "", el);
|
|
254
|
+
const span = import_l7_utils.DOM.create("span", "", label);
|
|
255
|
+
const { field, method } = this.markerLayerOption.clusterOption;
|
|
256
|
+
feature.properties.point_count = feature.properties.point_count || 1;
|
|
257
|
+
const text = field && method ? feature.properties["point_" + method] || feature.properties[field] : feature.properties.point_count;
|
|
258
|
+
span.textContent = text;
|
|
259
|
+
return el;
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
263
|
+
0 && (module.exports = {});
|
package/lib/marker.js
ADDED
|
@@ -0,0 +1,307 @@
|
|
|
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/marker.ts
|
|
20
|
+
var marker_exports = {};
|
|
21
|
+
__export(marker_exports, {
|
|
22
|
+
default: () => Marker
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(marker_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 Marker = class extends import_eventemitter3.EventEmitter {
|
|
29
|
+
constructor(option) {
|
|
30
|
+
super();
|
|
31
|
+
this.added = false;
|
|
32
|
+
this.eventHandle = (e) => {
|
|
33
|
+
this.emit(e.type, {
|
|
34
|
+
target: e,
|
|
35
|
+
data: this.markerOption.extData,
|
|
36
|
+
lngLat: this.lngLat
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
this.markerOption = {
|
|
40
|
+
...this.getDefault(),
|
|
41
|
+
...option
|
|
42
|
+
};
|
|
43
|
+
(0, import_l7_utils.bindAll)(["update", "onMove", "onUp", "addDragHandler", "onMapClick"], this);
|
|
44
|
+
this.init();
|
|
45
|
+
}
|
|
46
|
+
getMarkerLayerContainerSize() {
|
|
47
|
+
}
|
|
48
|
+
getDefault() {
|
|
49
|
+
return {
|
|
50
|
+
element: void 0,
|
|
51
|
+
anchor: import_l7_utils.anchorType.BOTTOM,
|
|
52
|
+
offsets: [0, 0],
|
|
53
|
+
color: "#5B8FF9",
|
|
54
|
+
draggable: false
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
addTo(scene) {
|
|
58
|
+
this.scene = scene;
|
|
59
|
+
this.mapsService = scene.get(import_l7_core.TYPES.IMapService);
|
|
60
|
+
this.sceneSerive = scene.get(import_l7_core.TYPES.ISceneService);
|
|
61
|
+
const { element } = this.markerOption;
|
|
62
|
+
this.mapsService.getMarkerContainer().appendChild(element);
|
|
63
|
+
this.registerMarkerEvent(element);
|
|
64
|
+
this.mapsService.on("camerachange", this.update);
|
|
65
|
+
this.mapsService.on("viewchange", this.update);
|
|
66
|
+
this.update();
|
|
67
|
+
this.added = true;
|
|
68
|
+
this.emit("added");
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
remove() {
|
|
72
|
+
if (this.mapsService) {
|
|
73
|
+
this.mapsService.off("click", this.onMapClick);
|
|
74
|
+
this.mapsService.off("move", this.update);
|
|
75
|
+
this.mapsService.off("moveend", this.update);
|
|
76
|
+
this.mapsService.off("mousedown", this.addDragHandler);
|
|
77
|
+
this.mapsService.off("touchstart", this.addDragHandler);
|
|
78
|
+
this.mapsService.off("mouseup", this.onUp);
|
|
79
|
+
this.mapsService.off("touchend", this.onUp);
|
|
80
|
+
}
|
|
81
|
+
this.unRegisterMarkerEvent();
|
|
82
|
+
this.removeAllListeners();
|
|
83
|
+
const { element } = this.markerOption;
|
|
84
|
+
if (element) {
|
|
85
|
+
import_l7_utils.DOM.remove(element);
|
|
86
|
+
}
|
|
87
|
+
if (this.popup) {
|
|
88
|
+
this.popup.remove();
|
|
89
|
+
}
|
|
90
|
+
return this;
|
|
91
|
+
}
|
|
92
|
+
setLnglat(lngLat) {
|
|
93
|
+
this.lngLat = lngLat;
|
|
94
|
+
if (Array.isArray(lngLat)) {
|
|
95
|
+
this.lngLat = {
|
|
96
|
+
lng: lngLat[0],
|
|
97
|
+
lat: lngLat[1]
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
if (this.popup) {
|
|
101
|
+
this.popup.setLnglat(this.lngLat);
|
|
102
|
+
}
|
|
103
|
+
this.update();
|
|
104
|
+
return this;
|
|
105
|
+
}
|
|
106
|
+
getLnglat() {
|
|
107
|
+
return this.lngLat;
|
|
108
|
+
}
|
|
109
|
+
getElement() {
|
|
110
|
+
return this.markerOption.element;
|
|
111
|
+
}
|
|
112
|
+
setElement(el) {
|
|
113
|
+
if (!this.added) {
|
|
114
|
+
this.once("added", () => {
|
|
115
|
+
this.setElement(el);
|
|
116
|
+
});
|
|
117
|
+
return this;
|
|
118
|
+
}
|
|
119
|
+
const { element } = this.markerOption;
|
|
120
|
+
if (element) {
|
|
121
|
+
import_l7_utils.DOM.remove(element);
|
|
122
|
+
}
|
|
123
|
+
this.markerOption.element = el;
|
|
124
|
+
this.init();
|
|
125
|
+
this.mapsService.getMarkerContainer().appendChild(el);
|
|
126
|
+
this.registerMarkerEvent(el);
|
|
127
|
+
this.update();
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
openPopup() {
|
|
131
|
+
if (!this.added) {
|
|
132
|
+
this.once("added", () => {
|
|
133
|
+
this.openPopup();
|
|
134
|
+
});
|
|
135
|
+
return this;
|
|
136
|
+
}
|
|
137
|
+
const popup = this.popup;
|
|
138
|
+
if (!popup) {
|
|
139
|
+
return this;
|
|
140
|
+
}
|
|
141
|
+
if (!popup.isOpen()) {
|
|
142
|
+
popup.addTo(this.scene);
|
|
143
|
+
}
|
|
144
|
+
return this;
|
|
145
|
+
}
|
|
146
|
+
closePopup() {
|
|
147
|
+
if (!this.added) {
|
|
148
|
+
this.once("added", () => {
|
|
149
|
+
this.closePopup();
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
const popup = this.popup;
|
|
153
|
+
if (popup) {
|
|
154
|
+
popup.remove();
|
|
155
|
+
}
|
|
156
|
+
return this;
|
|
157
|
+
}
|
|
158
|
+
setPopup(popup) {
|
|
159
|
+
this.popup = popup;
|
|
160
|
+
if (this.lngLat) {
|
|
161
|
+
this.popup.setLnglat(this.lngLat);
|
|
162
|
+
}
|
|
163
|
+
return this;
|
|
164
|
+
}
|
|
165
|
+
togglePopup() {
|
|
166
|
+
const popup = this.popup;
|
|
167
|
+
if (!popup) {
|
|
168
|
+
return this;
|
|
169
|
+
} else if (popup.isOpen()) {
|
|
170
|
+
popup.remove();
|
|
171
|
+
} else {
|
|
172
|
+
popup.addTo(this.scene);
|
|
173
|
+
}
|
|
174
|
+
return this;
|
|
175
|
+
}
|
|
176
|
+
getPopup() {
|
|
177
|
+
return this.popup;
|
|
178
|
+
}
|
|
179
|
+
getOffset() {
|
|
180
|
+
return this.markerOption.offsets;
|
|
181
|
+
}
|
|
182
|
+
setDraggable(draggable) {
|
|
183
|
+
throw new Error("Method not implemented.");
|
|
184
|
+
}
|
|
185
|
+
isDraggable() {
|
|
186
|
+
return this.markerOption.draggable;
|
|
187
|
+
}
|
|
188
|
+
getExtData() {
|
|
189
|
+
return this.markerOption.extData;
|
|
190
|
+
}
|
|
191
|
+
setExtData(data) {
|
|
192
|
+
this.markerOption.extData = data;
|
|
193
|
+
}
|
|
194
|
+
update() {
|
|
195
|
+
if (!this.mapsService) {
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
const { element, anchor } = this.markerOption;
|
|
199
|
+
this.updatePosition();
|
|
200
|
+
import_l7_utils.DOM.setTransform(element, `${import_l7_utils.anchorTranslate[anchor]}`);
|
|
201
|
+
}
|
|
202
|
+
onMapClick(e) {
|
|
203
|
+
const { element } = this.markerOption;
|
|
204
|
+
if (this.popup && element) {
|
|
205
|
+
this.togglePopup();
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
getCurrentContainerSize() {
|
|
209
|
+
const container = this.mapsService.getContainer();
|
|
210
|
+
return {
|
|
211
|
+
containerHeight: (container == null ? void 0 : container.scrollHeight) || 0,
|
|
212
|
+
containerWidth: (container == null ? void 0 : container.scrollWidth) || 0,
|
|
213
|
+
bounds: this.mapsService.getBounds()
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
updatePosition() {
|
|
217
|
+
if (!this.mapsService) {
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
const { element, offsets } = this.markerOption;
|
|
221
|
+
const { lng, lat } = this.lngLat;
|
|
222
|
+
const pos = this.mapsService.lngLatToContainer([lng, lat]);
|
|
223
|
+
if (element) {
|
|
224
|
+
element.style.display = "block";
|
|
225
|
+
element.style.whiteSpace = "nowrap";
|
|
226
|
+
const { containerHeight, containerWidth, bounds } = this.getMarkerLayerContainerSize() || this.getCurrentContainerSize();
|
|
227
|
+
if (!bounds)
|
|
228
|
+
return;
|
|
229
|
+
if (Math.abs(bounds[0][0]) > 180 || Math.abs(bounds[1][0]) > 180) {
|
|
230
|
+
if (pos.x > containerWidth) {
|
|
231
|
+
const newPos = this.mapsService.lngLatToContainer([lng - 360, lat]);
|
|
232
|
+
pos.x = newPos.x;
|
|
233
|
+
}
|
|
234
|
+
if (pos.x < 0) {
|
|
235
|
+
const newPos = this.mapsService.lngLatToContainer([lng + 360, lat]);
|
|
236
|
+
pos.x = newPos.x;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
if (pos.x > containerWidth || pos.x < 0 || pos.y > containerHeight || pos.y < 0) {
|
|
240
|
+
element.style.display = "none";
|
|
241
|
+
}
|
|
242
|
+
element.style.left = pos.x + offsets[0] + "px";
|
|
243
|
+
element.style.top = pos.y - offsets[1] + "px";
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
init() {
|
|
247
|
+
let { element } = this.markerOption;
|
|
248
|
+
const { color, anchor } = this.markerOption;
|
|
249
|
+
if (!element) {
|
|
250
|
+
this.defaultMarker = true;
|
|
251
|
+
element = import_l7_utils.DOM.create("div");
|
|
252
|
+
this.markerOption.element = element;
|
|
253
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
254
|
+
svg.setAttributeNS(null, "display", "block");
|
|
255
|
+
svg.setAttributeNS(null, "height", "48px");
|
|
256
|
+
svg.setAttributeNS(null, "width", "48px");
|
|
257
|
+
svg.setAttributeNS(null, "viewBox", "0 0 1024 1024");
|
|
258
|
+
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
259
|
+
path.setAttributeNS(null, "d", "M512 490.666667C453.12 490.666667 405.333333 442.88 405.333333 384 405.333333 325.12 453.12 277.333333 512 277.333333 570.88 277.333333 618.666667 325.12 618.666667 384 618.666667 442.88 570.88 490.666667 512 490.666667M512 85.333333C346.88 85.333333 213.333333 218.88 213.333333 384 213.333333 608 512 938.666667 512 938.666667 512 938.666667 810.666667 608 810.666667 384 810.666667 218.88 677.12 85.333333 512 85.333333Z");
|
|
260
|
+
path.setAttributeNS(null, "fill", color);
|
|
261
|
+
svg.appendChild(path);
|
|
262
|
+
element.appendChild(svg);
|
|
263
|
+
}
|
|
264
|
+
import_l7_utils.DOM.addClass(element, "l7-marker");
|
|
265
|
+
Object.keys(this.markerOption.style || {}).forEach((key) => {
|
|
266
|
+
var _a, _b;
|
|
267
|
+
const value = ((_a = this.markerOption) == null ? void 0 : _a.style) && ((_b = this.markerOption) == null ? void 0 : _b.style[key]);
|
|
268
|
+
if (element) {
|
|
269
|
+
element.style[key] = value;
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
element.addEventListener("click", (e) => {
|
|
273
|
+
this.onMapClick(e);
|
|
274
|
+
});
|
|
275
|
+
element.addEventListener("click", this.eventHandle);
|
|
276
|
+
(0, import_l7_utils.applyAnchorClass)(element, anchor, "marker");
|
|
277
|
+
}
|
|
278
|
+
registerMarkerEvent(element) {
|
|
279
|
+
element.addEventListener("mousemove", this.eventHandle);
|
|
280
|
+
element.addEventListener("click", this.eventHandle);
|
|
281
|
+
element.addEventListener("mousedown", this.eventHandle);
|
|
282
|
+
element.addEventListener("mouseup", this.eventHandle);
|
|
283
|
+
element.addEventListener("dblclick", this.eventHandle);
|
|
284
|
+
element.addEventListener("contextmenu", this.eventHandle);
|
|
285
|
+
element.addEventListener("mouseover", this.eventHandle);
|
|
286
|
+
element.addEventListener("mouseout", this.eventHandle);
|
|
287
|
+
}
|
|
288
|
+
unRegisterMarkerEvent() {
|
|
289
|
+
const element = this.getElement();
|
|
290
|
+
element.removeEventListener("mousemove", this.eventHandle);
|
|
291
|
+
element.removeEventListener("click", this.eventHandle);
|
|
292
|
+
element.removeEventListener("mousedown", this.eventHandle);
|
|
293
|
+
element.removeEventListener("mouseup", this.eventHandle);
|
|
294
|
+
element.removeEventListener("dblclick", this.eventHandle);
|
|
295
|
+
element.removeEventListener("contextmenu", this.eventHandle);
|
|
296
|
+
element.removeEventListener("mouseover", this.eventHandle);
|
|
297
|
+
element.removeEventListener("mouseout", this.eventHandle);
|
|
298
|
+
}
|
|
299
|
+
addDragHandler(e) {
|
|
300
|
+
throw new Error("Method not implemented.");
|
|
301
|
+
}
|
|
302
|
+
onUp(e) {
|
|
303
|
+
throw new Error("Method not implemented.");
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
307
|
+
0 && (module.exports = {});
|