mapboxgl-tools 1.7.6 → 1.7.7
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/dist/ui.es.js +108 -70
- package/dist/ui.umd.js +1 -1
- package/package.json +1 -1
package/dist/ui.es.js
CHANGED
|
@@ -22111,6 +22111,7 @@ const IMAGE_POSCONTROL_NOR = "IMAGE_POSCONTROL_NOR";
|
|
|
22111
22111
|
const SOURCE_WBIOKR_POSCONTROL = "SOURCE_WBIOKR_POSCONTROL";
|
|
22112
22112
|
const LAYER_WBIOKR_POSCONTROL = "LAYER_WBIOKR_POSCONTROL";
|
|
22113
22113
|
const options$1 = {
|
|
22114
|
+
type: "feature",
|
|
22114
22115
|
title: "\u5B9A\u4F4D\u6492\u70B9",
|
|
22115
22116
|
normalColor: "#000",
|
|
22116
22117
|
layout: {
|
|
@@ -22147,6 +22148,7 @@ class PositionControl extends KeyboardControl {
|
|
|
22147
22148
|
};
|
|
22148
22149
|
this.value = "";
|
|
22149
22150
|
this.index = -1;
|
|
22151
|
+
this.markers = null;
|
|
22150
22152
|
}
|
|
22151
22153
|
get mainClass() {
|
|
22152
22154
|
return `wbiokr-control-${this.name}`;
|
|
@@ -22173,33 +22175,52 @@ class PositionControl extends KeyboardControl {
|
|
|
22173
22175
|
return this.index;
|
|
22174
22176
|
}
|
|
22175
22177
|
set current(val) {
|
|
22176
|
-
this.
|
|
22177
|
-
|
|
22178
|
-
|
|
22179
|
-
|
|
22180
|
-
|
|
22181
|
-
|
|
22182
|
-
|
|
22183
|
-
|
|
22184
|
-
|
|
22185
|
-
|
|
22186
|
-
|
|
22187
|
-
|
|
22188
|
-
|
|
22189
|
-
|
|
22190
|
-
|
|
22191
|
-
});
|
|
22192
|
-
this._map.getSource(SOURCE_WBIOKR_POSCONTROL).setData({
|
|
22193
|
-
type: "FeatureCollection",
|
|
22194
|
-
features
|
|
22195
|
-
});
|
|
22196
|
-
const currentLoc = newLocs[val];
|
|
22197
|
-
if (currentLoc) {
|
|
22198
|
-
this._map.flyTo({
|
|
22199
|
-
center: currentLoc,
|
|
22200
|
-
essential: false,
|
|
22201
|
-
duration: 100
|
|
22178
|
+
if (this.options.type === "feature") {
|
|
22179
|
+
if (this._map.getSource(SOURCE_WBIOKR_POSCONTROL)) {
|
|
22180
|
+
const newLocs = this._coords();
|
|
22181
|
+
const features = newLocs.map((loc, INDEX) => {
|
|
22182
|
+
return {
|
|
22183
|
+
type: "Feature",
|
|
22184
|
+
geometry: {
|
|
22185
|
+
type: "Point",
|
|
22186
|
+
coordinates: loc
|
|
22187
|
+
},
|
|
22188
|
+
properties: {
|
|
22189
|
+
current: Number(val) === INDEX,
|
|
22190
|
+
index: INDEX
|
|
22191
|
+
}
|
|
22192
|
+
};
|
|
22202
22193
|
});
|
|
22194
|
+
this._map.getSource(SOURCE_WBIOKR_POSCONTROL).setData({
|
|
22195
|
+
type: "FeatureCollection",
|
|
22196
|
+
features
|
|
22197
|
+
});
|
|
22198
|
+
const currentLoc = newLocs[val];
|
|
22199
|
+
if (currentLoc) {
|
|
22200
|
+
this._map.flyTo({
|
|
22201
|
+
center: currentLoc,
|
|
22202
|
+
essential: false,
|
|
22203
|
+
duration: 100
|
|
22204
|
+
});
|
|
22205
|
+
}
|
|
22206
|
+
}
|
|
22207
|
+
} else if (this.options.type === "marker") {
|
|
22208
|
+
if (!this.markers)
|
|
22209
|
+
return;
|
|
22210
|
+
const currentMarker = this.markers[val];
|
|
22211
|
+
if (!currentMarker)
|
|
22212
|
+
return;
|
|
22213
|
+
const lngLat = currentMarker.getLngLat();
|
|
22214
|
+
this._map.flyTo({
|
|
22215
|
+
center: [lngLat.lng, lngLat.lat],
|
|
22216
|
+
essential: false,
|
|
22217
|
+
duration: 100
|
|
22218
|
+
});
|
|
22219
|
+
const ele = currentMarker.getElement();
|
|
22220
|
+
ele.setAttribute("src", IconActive);
|
|
22221
|
+
const prevMarker = this.markers[this.index];
|
|
22222
|
+
if (prevMarker) {
|
|
22223
|
+
prevMarker.getElement().setAttribute("src", IconNormal);
|
|
22203
22224
|
}
|
|
22204
22225
|
}
|
|
22205
22226
|
const currentDom = this._container.querySelector(".wbokr-position-selected");
|
|
@@ -22210,6 +22231,7 @@ class PositionControl extends KeyboardControl {
|
|
|
22210
22231
|
if (nextDom) {
|
|
22211
22232
|
nextDom.className += " wbokr-position-selected";
|
|
22212
22233
|
}
|
|
22234
|
+
this.index = val;
|
|
22213
22235
|
}
|
|
22214
22236
|
onAdd(map) {
|
|
22215
22237
|
this._map = map;
|
|
@@ -22244,19 +22266,22 @@ class PositionControl extends KeyboardControl {
|
|
|
22244
22266
|
this._map.on("click", (mapEvent) => {
|
|
22245
22267
|
if (!this.flag)
|
|
22246
22268
|
return;
|
|
22247
|
-
|
|
22248
|
-
|
|
22249
|
-
|
|
22250
|
-
|
|
22251
|
-
|
|
22252
|
-
|
|
22269
|
+
if (this.options.type === "feature") {
|
|
22270
|
+
const feas = this._map.queryRenderedFeatures([mapEvent.point.x, mapEvent.point.y]);
|
|
22271
|
+
const targetFea = feas.find((o) => o.source === SOURCE_WBIOKR_POSCONTROL && o.layer.id === LAYER_WBIOKR_POSCONTROL);
|
|
22272
|
+
if (!targetFea)
|
|
22273
|
+
return;
|
|
22274
|
+
const newIndex = targetFea.properties.index;
|
|
22275
|
+
this.current = newIndex;
|
|
22276
|
+
}
|
|
22253
22277
|
});
|
|
22254
22278
|
}
|
|
22255
22279
|
_open() {
|
|
22256
|
-
this._onOpen();
|
|
22280
|
+
this._onOpen && this._onOpen();
|
|
22257
22281
|
}
|
|
22258
22282
|
_close() {
|
|
22259
|
-
this.
|
|
22283
|
+
this.markers = null;
|
|
22284
|
+
this._onClose && this._onClose();
|
|
22260
22285
|
}
|
|
22261
22286
|
_resetData() {
|
|
22262
22287
|
this.flagValue = false;
|
|
@@ -22264,45 +22289,58 @@ class PositionControl extends KeyboardControl {
|
|
|
22264
22289
|
_navigate() {
|
|
22265
22290
|
this.current = -1;
|
|
22266
22291
|
const newLocs = this._coords();
|
|
22267
|
-
|
|
22268
|
-
|
|
22269
|
-
|
|
22270
|
-
|
|
22271
|
-
|
|
22272
|
-
|
|
22273
|
-
|
|
22274
|
-
|
|
22275
|
-
|
|
22276
|
-
|
|
22277
|
-
|
|
22278
|
-
|
|
22279
|
-
|
|
22280
|
-
|
|
22281
|
-
this._map.
|
|
22282
|
-
|
|
22283
|
-
|
|
22292
|
+
if (this.options.type === "feature") {
|
|
22293
|
+
const features = newLocs.map((loc, index2) => {
|
|
22294
|
+
return {
|
|
22295
|
+
type: "Feature",
|
|
22296
|
+
geometry: {
|
|
22297
|
+
type: "Point",
|
|
22298
|
+
coordinates: loc
|
|
22299
|
+
},
|
|
22300
|
+
properties: {
|
|
22301
|
+
current: false,
|
|
22302
|
+
index: index2
|
|
22303
|
+
}
|
|
22304
|
+
};
|
|
22305
|
+
});
|
|
22306
|
+
if (!this._map.getSource(SOURCE_WBIOKR_POSCONTROL)) {
|
|
22307
|
+
this._map.addSource(SOURCE_WBIOKR_POSCONTROL, {
|
|
22308
|
+
type: "geojson",
|
|
22309
|
+
data: {
|
|
22310
|
+
type: "FeatureCollection",
|
|
22311
|
+
features
|
|
22312
|
+
}
|
|
22313
|
+
});
|
|
22314
|
+
} else {
|
|
22315
|
+
this._map.getSource(SOURCE_WBIOKR_POSCONTROL).setData({
|
|
22284
22316
|
type: "FeatureCollection",
|
|
22285
22317
|
features
|
|
22286
|
-
}
|
|
22287
|
-
}
|
|
22288
|
-
|
|
22289
|
-
|
|
22290
|
-
|
|
22291
|
-
|
|
22292
|
-
|
|
22293
|
-
|
|
22294
|
-
|
|
22295
|
-
|
|
22296
|
-
|
|
22297
|
-
|
|
22298
|
-
|
|
22299
|
-
|
|
22300
|
-
|
|
22301
|
-
|
|
22302
|
-
|
|
22303
|
-
|
|
22304
|
-
|
|
22318
|
+
});
|
|
22319
|
+
}
|
|
22320
|
+
if (!this._map.getLayer(LAYER_WBIOKR_POSCONTROL)) {
|
|
22321
|
+
this._map.addLayer({
|
|
22322
|
+
type: "symbol",
|
|
22323
|
+
id: LAYER_WBIOKR_POSCONTROL,
|
|
22324
|
+
source: SOURCE_WBIOKR_POSCONTROL,
|
|
22325
|
+
layout: {
|
|
22326
|
+
...this.options.layout
|
|
22327
|
+
},
|
|
22328
|
+
paint: {
|
|
22329
|
+
...this.options.paint
|
|
22330
|
+
}
|
|
22331
|
+
});
|
|
22332
|
+
}
|
|
22333
|
+
} else if (this.options.type === "marker") {
|
|
22334
|
+
const newMarkers = newLocs.map((loc, index2) => {
|
|
22335
|
+
const el = document.createElement("img");
|
|
22336
|
+
el.className = "wbiokr-marker w-30 z-1";
|
|
22337
|
+
el.src = IconNormal;
|
|
22338
|
+
el.onclick = () => {
|
|
22339
|
+
this.current = index2;
|
|
22340
|
+
};
|
|
22341
|
+
return new mapboxgl.Marker(el).setLngLat(loc).addTo(this._map);
|
|
22305
22342
|
});
|
|
22343
|
+
this.markers = newMarkers;
|
|
22306
22344
|
}
|
|
22307
22345
|
const ul = this._container.querySelector("ul");
|
|
22308
22346
|
ul.innerHTML = "";
|