@mapvx/web-js 1.2.0 → 1.2.2
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/README.md +2 -0
- package/dist/cjs/controllers/routeController.js +19 -19
- package/dist/cjs/controllers/routeController.js.map +1 -1
- package/dist/cjs/domain/models/circle.js +38 -3
- package/dist/cjs/domain/models/circle.js.map +1 -1
- package/dist/cjs/domain/models/mapConfig.js +10 -1
- package/dist/cjs/domain/models/mapConfig.js.map +1 -1
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/logger/logger.js +13 -8
- package/dist/cjs/logger/logger.js.map +1 -1
- package/dist/cjs/logger/rollbar.js +11 -6
- package/dist/cjs/logger/rollbar.js.map +1 -1
- package/dist/cjs/map/map.js +200 -52
- package/dist/cjs/map/map.js.map +1 -1
- package/dist/cjs/map/mapInteractionOptions.js +56 -0
- package/dist/cjs/map/mapInteractionOptions.js.map +1 -0
- package/dist/cjs/repository/repository.js +25 -26
- package/dist/cjs/repository/repository.js.map +1 -1
- package/dist/cjs/repository/requester.js +24 -27
- package/dist/cjs/repository/requester.js.map +1 -1
- package/dist/cjs/sdk.js +18 -0
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/cjs/utils/semaphore.js +143 -0
- package/dist/cjs/utils/semaphore.js.map +1 -0
- package/dist/es/controllers/routeController.d.ts.map +1 -1
- package/dist/es/controllers/routeController.js +19 -19
- package/dist/es/controllers/routeController.js.map +1 -1
- package/dist/es/domain/models/circle.d.ts +39 -0
- package/dist/es/domain/models/circle.d.ts.map +1 -1
- package/dist/es/domain/models/circle.js +36 -2
- package/dist/es/domain/models/circle.js.map +1 -1
- package/dist/es/domain/models/configuration.d.ts +8 -0
- package/dist/es/domain/models/configuration.d.ts.map +1 -1
- package/dist/es/domain/models/mapConfig.d.ts +118 -3
- package/dist/es/domain/models/mapConfig.d.ts.map +1 -1
- package/dist/es/domain/models/mapConfig.js +9 -0
- package/dist/es/domain/models/mapConfig.js.map +1 -1
- package/dist/es/index.d.ts +2 -1
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +2 -0
- package/dist/es/index.js.map +1 -1
- package/dist/es/logger/logger.d.ts.map +1 -1
- package/dist/es/logger/logger.js +13 -8
- package/dist/es/logger/logger.js.map +1 -1
- package/dist/es/logger/rollbar.d.ts.map +1 -1
- package/dist/es/logger/rollbar.js +11 -6
- package/dist/es/logger/rollbar.js.map +1 -1
- package/dist/es/map/map.d.ts +103 -1
- package/dist/es/map/map.d.ts.map +1 -1
- package/dist/es/map/map.js +202 -54
- package/dist/es/map/map.js.map +1 -1
- package/dist/es/map/mapInteractionOptions.d.ts +37 -0
- package/dist/es/map/mapInteractionOptions.d.ts.map +1 -0
- package/dist/es/map/mapInteractionOptions.js +51 -0
- package/dist/es/map/mapInteractionOptions.js.map +1 -0
- package/dist/es/repository/repository.d.ts +0 -1
- package/dist/es/repository/repository.d.ts.map +1 -1
- package/dist/es/repository/repository.js +25 -26
- package/dist/es/repository/repository.js.map +1 -1
- package/dist/es/repository/requester.d.ts +0 -2
- package/dist/es/repository/requester.d.ts.map +1 -1
- package/dist/es/repository/requester.js +24 -27
- package/dist/es/repository/requester.js.map +1 -1
- package/dist/es/sdk.d.ts +2 -0
- package/dist/es/sdk.d.ts.map +1 -1
- package/dist/es/sdk.js +18 -0
- package/dist/es/sdk.js.map +1 -1
- package/dist/es/utils/semaphore.d.ts +70 -0
- package/dist/es/utils/semaphore.d.ts.map +1 -0
- package/dist/es/utils/semaphore.js +139 -0
- package/dist/es/utils/semaphore.js.map +1 -0
- package/dist/umd/index.js +788 -271
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -1
package/dist/es/map/map.js
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
import maplibregl, { LngLatBounds, Map, NavigationControl, setRTLTextPlugin, } from "maplibre-gl";
|
|
2
|
+
import { Semaphore } from "../utils/semaphore";
|
|
2
3
|
/** Shared GeoJSON source holding every circle drawn through the circle API. */
|
|
3
4
|
const CIRCLE_SOURCE_ID = "mapvx-circles";
|
|
4
5
|
/** Fill layer rendering the translucent interior of the circles. */
|
|
5
6
|
const CIRCLE_FILL_LAYER_ID = "mapvx-circles-fill";
|
|
6
7
|
/** Line layer rendering the circle outlines. */
|
|
7
8
|
const CIRCLE_LINE_LAYER_ID = "mapvx-circles-line";
|
|
9
|
+
/**
|
|
10
|
+
* Layer-id suffix per circle render order. The default placement keeps the
|
|
11
|
+
* unsuffixed ids so existing consumers referencing them keep working.
|
|
12
|
+
*/
|
|
13
|
+
const CIRCLE_LAYER_SUFFIXES = {
|
|
14
|
+
aboveBasemap: "",
|
|
15
|
+
belowLabels: "-below-labels",
|
|
16
|
+
top: "-top",
|
|
17
|
+
};
|
|
18
|
+
/** Fill/line layer ids for one circle render-order bucket. */
|
|
19
|
+
function circleLayerIdsFor(order) {
|
|
20
|
+
const suffix = CIRCLE_LAYER_SUFFIXES[order];
|
|
21
|
+
return { fill: CIRCLE_FILL_LAYER_ID + suffix, line: CIRCLE_LINE_LAYER_ID + suffix };
|
|
22
|
+
}
|
|
23
|
+
/** True for the layer ids owned by the circle API, regardless of bucket. */
|
|
24
|
+
function isCircleLayerId(id) {
|
|
25
|
+
return id.startsWith(CIRCLE_FILL_LAYER_ID) || id.startsWith(CIRCLE_LINE_LAYER_ID);
|
|
26
|
+
}
|
|
8
27
|
// Flag to track if cached-tile protocol has been registered
|
|
9
28
|
let cachedTileProtocolRegistered = false;
|
|
10
29
|
/**
|
|
@@ -25,21 +44,36 @@ function deepClone(obj) {
|
|
|
25
44
|
/**
|
|
26
45
|
* Register a custom protocol for cached tiles that routes requests through the main thread.
|
|
27
46
|
* This allows the service worker to intercept and cache tile requests.
|
|
47
|
+
*
|
|
48
|
+
* Wraps fetches in a {@link Semaphore} so tile CDN / WAFs are not hit with
|
|
49
|
+
* unbounded parallel requests (same host as the service worker cache). The
|
|
50
|
+
* semaphore is created once with the limit from the first map's config; later
|
|
51
|
+
* calls are no-ops because the protocol can only be registered once globally
|
|
52
|
+
* on MapLibre.
|
|
53
|
+
*
|
|
54
|
+
* @param maxConcurrentFetches - Maximum number of in-flight tile fetches.
|
|
28
55
|
*/
|
|
29
|
-
function registerCachedTileProtocol() {
|
|
56
|
+
function registerCachedTileProtocol(maxConcurrentFetches) {
|
|
30
57
|
if (cachedTileProtocolRegistered)
|
|
31
58
|
return;
|
|
59
|
+
const semaphore = new Semaphore(maxConcurrentFetches);
|
|
32
60
|
maplibregl.addProtocol("cached-tile", (params, abortController) => {
|
|
33
|
-
// Convert cached-tile:// URL back to https://
|
|
34
61
|
const url = params.url.replace("cached-tile://", "https://");
|
|
35
|
-
|
|
62
|
+
// Pass the abort signal to acquire() so a request cancelled while still
|
|
63
|
+
// queued (e.g. during rapid zoom) drops out of the FIFO queue instead of
|
|
64
|
+
// waiting for a slot just to bail. release() runs only inside this chain,
|
|
65
|
+
// i.e. only after a slot was actually granted.
|
|
66
|
+
return semaphore.acquire(abortController.signal).then(() => fetch(url, { signal: abortController.signal })
|
|
36
67
|
.then((response) => {
|
|
37
68
|
if (!response.ok) {
|
|
38
69
|
throw new Error(`HTTP error! status: ${response.status}`);
|
|
39
70
|
}
|
|
40
71
|
return response.arrayBuffer();
|
|
41
72
|
})
|
|
42
|
-
.then((data) => ({ data }))
|
|
73
|
+
.then((data) => ({ data }))
|
|
74
|
+
.finally(() => {
|
|
75
|
+
semaphore.release();
|
|
76
|
+
}));
|
|
43
77
|
});
|
|
44
78
|
cachedTileProtocolRegistered = true;
|
|
45
79
|
}
|
|
@@ -98,14 +132,15 @@ import { RouteController } from "../controllers/routeController";
|
|
|
98
132
|
import { rtlLanguages } from "../domain/models/_rtl";
|
|
99
133
|
import { InternalAnimationConfig, InternalAnimationDrawingConfig, } from "../domain/models/animation";
|
|
100
134
|
import { Loggeable } from "../domain/models/loggeable";
|
|
101
|
-
import { DEFAULT_TILE_CACHE_CONFIG, } from "../domain/models/mapConfig";
|
|
102
|
-
import { circleRing, MAPVX_BRAND_COLOR, resolveCircleConfig, } from "../domain/models/circle";
|
|
135
|
+
import { DEFAULT_TILE_CACHE_CONFIG, MAPLIBRE_MAX_TILE_CACHE_HARD_CAP, } from "../domain/models/mapConfig";
|
|
136
|
+
import { CIRCLE_RENDER_ORDERS, circleRing, cloneCircleRecord, MAPVX_BRAND_COLOR, resolveCircleConfig, } from "../domain/models/circle";
|
|
103
137
|
import { MarkerAttribute } from "../domain/models/marker";
|
|
104
138
|
import { MVXRoute } from "../domain/models/route";
|
|
105
139
|
import { InternalDrawRouteConfiguration, InternalGetRouteConfiguration, } from "../domain/models/routeConfiguration";
|
|
106
140
|
import { Repository } from "../repository/repository";
|
|
107
141
|
import { getBoundingBox } from "../utils/utils";
|
|
108
142
|
import { extractStepCoordinates } from "../utils/route-utils";
|
|
143
|
+
import { buildInteractionOptions, shouldDisableTouchRotation } from "./mapInteractionOptions";
|
|
109
144
|
/**
|
|
110
145
|
* Class to interact with the map.
|
|
111
146
|
* @category Map
|
|
@@ -145,8 +180,11 @@ export class InternalMapVXMap extends Loggeable {
|
|
|
145
180
|
this.watchPositionID = undefined;
|
|
146
181
|
this.onFloorChange = mapConfig.onFloorChange;
|
|
147
182
|
this.onParentPlaceChange = mapConfig.onParentPlaceChange;
|
|
148
|
-
|
|
149
|
-
|
|
183
|
+
this.tileCacheConfig = (() => {
|
|
184
|
+
const merged = Object.assign(Object.assign({}, DEFAULT_TILE_CACHE_CONFIG), mapConfig.tileCache);
|
|
185
|
+
merged.maxTiles = Math.min(merged.maxTiles, MAPLIBRE_MAX_TILE_CACHE_HARD_CAP);
|
|
186
|
+
return merged;
|
|
187
|
+
})();
|
|
150
188
|
if (mapConfig.parentPlaceId != null) {
|
|
151
189
|
this.initialPlaceDetailSetUp(mapConfig.parentPlaceId, mapConfig.authToken);
|
|
152
190
|
}
|
|
@@ -243,28 +281,17 @@ export class InternalMapVXMap extends Loggeable {
|
|
|
243
281
|
.catch(console.error);
|
|
244
282
|
}
|
|
245
283
|
onMapStyleLoaded(mapConfig, container, style) {
|
|
246
|
-
var _a, _b, _c;
|
|
284
|
+
var _a, _b, _c, _d, _e;
|
|
247
285
|
// Determine if service worker caching should be enabled
|
|
248
286
|
const useServiceWorkerCaching = this.tileCacheConfig.enabled && this.tileCacheConfig.persistToServiceWorker;
|
|
249
|
-
// Register cached-tile protocol only if service worker caching is enabled
|
|
250
287
|
if (useServiceWorkerCaching) {
|
|
251
|
-
registerCachedTileProtocol();
|
|
288
|
+
registerCachedTileProtocol(this.tileCacheConfig.maxConcurrentTileFetches);
|
|
252
289
|
}
|
|
253
290
|
// Transform tile URLs only if service worker caching is enabled
|
|
254
291
|
const finalStyle = useServiceWorkerCaching ? this.transformStyleForCaching(style) : style;
|
|
255
|
-
const mapOptions = {
|
|
256
|
-
container,
|
|
257
|
-
style: finalStyle,
|
|
258
|
-
center: mapConfig.center,
|
|
259
|
-
zoom: mapConfig.zoom,
|
|
260
|
-
pitch: (_a = mapConfig.pitch) !== null && _a !== void 0 ? _a : 0,
|
|
261
|
-
attributionControl: false,
|
|
262
|
-
maplibreLogo: false,
|
|
263
|
-
bearingSnap: (_b = mapConfig.bearingSnap) !== null && _b !== void 0 ? _b : 0,
|
|
264
|
-
cancelPendingTileRequestsWhileZooming: false,
|
|
292
|
+
const mapOptions = Object.assign({ container, style: finalStyle, center: mapConfig.center, zoom: mapConfig.zoom, pitch: (_a = mapConfig.pitch) !== null && _a !== void 0 ? _a : 0, attributionControl: false, maplibreLogo: false, bearingSnap: (_b = mapConfig.bearingSnap) !== null && _b !== void 0 ? _b : 0, cancelPendingTileRequestsWhileZooming: true,
|
|
265
293
|
// Use configured maxTiles for MapLibre's memory cache
|
|
266
|
-
maxTileCacheSize: this.tileCacheConfig.maxTiles,
|
|
267
|
-
};
|
|
294
|
+
maxTileCacheSize: this.tileCacheConfig.maxTiles }, buildInteractionOptions(mapConfig));
|
|
268
295
|
if (mapConfig.maxZoom)
|
|
269
296
|
mapOptions.maxZoom = mapConfig.maxZoom;
|
|
270
297
|
if (mapConfig.minZoom)
|
|
@@ -274,10 +301,15 @@ export class InternalMapVXMap extends Loggeable {
|
|
|
274
301
|
mapOptions.maxBounds = new LngLatBounds([boundingBox[0].lng, boundingBox[0].lat], [boundingBox[1].lng, boundingBox[1].lat]);
|
|
275
302
|
}
|
|
276
303
|
this.map = new Map(mapOptions);
|
|
304
|
+
// When rotation is disabled we still want pinch-to-zoom to work, so the
|
|
305
|
+
// two-finger rotation is turned off here instead of via the constructor.
|
|
306
|
+
if (shouldDisableTouchRotation(mapConfig)) {
|
|
307
|
+
(_d = (_c = this.map.touchZoomRotate) === null || _c === void 0 ? void 0 : _c.disableRotation) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
308
|
+
}
|
|
277
309
|
this.map.addControl(new NavigationControl({
|
|
278
310
|
showCompass: mapConfig.showCompass !== undefined ? mapConfig.showCompass : true,
|
|
279
311
|
showZoom: mapConfig.showZoom !== undefined ? mapConfig.showZoom : true,
|
|
280
|
-
}), (
|
|
312
|
+
}), (_e = mapConfig.navigationPosition) !== null && _e !== void 0 ? _e : "top-right");
|
|
281
313
|
this.map.on("load", () => {
|
|
282
314
|
var _a;
|
|
283
315
|
this.whenStyleUpdates(style);
|
|
@@ -495,6 +527,19 @@ export class InternalMapVXMap extends Loggeable {
|
|
|
495
527
|
}
|
|
496
528
|
setLang(lang) {
|
|
497
529
|
this.repository.setLang(lang);
|
|
530
|
+
if (rtlLanguages.includes(lang)) {
|
|
531
|
+
this.setRTLSupport();
|
|
532
|
+
}
|
|
533
|
+
// setLayersForLanguage reads this.map.getStyle()?.layers, which is empty
|
|
534
|
+
// until the style finishes loading. If setLang is called right after
|
|
535
|
+
// createMap (before the "load" event), apply it once the style is ready
|
|
536
|
+
// so the language change is not silently dropped.
|
|
537
|
+
if (this.map.isStyleLoaded()) {
|
|
538
|
+
this.setLayersForLanguage(lang);
|
|
539
|
+
}
|
|
540
|
+
else {
|
|
541
|
+
this.map.once("load", () => this.setLayersForLanguage(lang));
|
|
542
|
+
}
|
|
498
543
|
}
|
|
499
544
|
setParentPlace(place, updateStyle, onStyleReady) {
|
|
500
545
|
this.changeParentPlaceTo(place, updateStyle, onStyleReady);
|
|
@@ -654,10 +699,11 @@ export class InternalMapVXMap extends Loggeable {
|
|
|
654
699
|
}
|
|
655
700
|
}
|
|
656
701
|
getCircle(circleId) {
|
|
657
|
-
|
|
702
|
+
const circle = this.circles.find((c) => c.id === circleId);
|
|
703
|
+
return circle ? cloneCircleRecord(circle) : undefined;
|
|
658
704
|
}
|
|
659
705
|
getCircles() {
|
|
660
|
-
return this.circles.
|
|
706
|
+
return this.circles.map(cloneCircleRecord);
|
|
661
707
|
}
|
|
662
708
|
hasCircle(circleId) {
|
|
663
709
|
return this.circles.some((c) => c.id === circleId);
|
|
@@ -683,7 +729,7 @@ export class InternalMapVXMap extends Loggeable {
|
|
|
683
729
|
throw new Error(`Invalid radiusMeters: ${radiusMeters}. Must be a positive finite number.`);
|
|
684
730
|
}
|
|
685
731
|
}
|
|
686
|
-
circle.coordinate = center;
|
|
732
|
+
circle.coordinate = { lat: center.lat, lng: center.lng };
|
|
687
733
|
if (radiusMeters !== undefined) {
|
|
688
734
|
circle.radiusMeters = radiusMeters;
|
|
689
735
|
}
|
|
@@ -797,6 +843,7 @@ export class InternalMapVXMap extends Loggeable {
|
|
|
797
843
|
strokeColor: circle.strokeColor,
|
|
798
844
|
strokeWidth: circle.strokeWidth,
|
|
799
845
|
strokeOpacity: circle.strokeOpacity,
|
|
846
|
+
renderOrder: circle.renderOrder,
|
|
800
847
|
},
|
|
801
848
|
geometry: {
|
|
802
849
|
type: "Polygon",
|
|
@@ -814,8 +861,43 @@ export class InternalMapVXMap extends Loggeable {
|
|
|
814
861
|
* time: a style that is still loading simply rejects the calls, and the
|
|
815
862
|
* styledata listener retries once the style is ready.
|
|
816
863
|
*/
|
|
864
|
+
/**
|
|
865
|
+
* Resolves the layer id to insert circle layers before, for one render
|
|
866
|
+
* order. `undefined` means "append on top".
|
|
867
|
+
*
|
|
868
|
+
* `aboveBasemap` finds the topmost non-symbol layer of the style and
|
|
869
|
+
* inserts before the first symbol layer that follows it. On indoor styles
|
|
870
|
+
* the floor-plate and building polygons are ordered after the first symbol
|
|
871
|
+
* layer, so anchoring on the topmost geometry layer — instead of the first
|
|
872
|
+
* symbol layer — guarantees circles are never occluded by basemap fills
|
|
873
|
+
* while still rendering below the labels that follow them.
|
|
874
|
+
*/
|
|
875
|
+
circleBeforeIdFor(order) {
|
|
876
|
+
var _a, _b, _c, _d;
|
|
877
|
+
if (order === "top")
|
|
878
|
+
return undefined;
|
|
879
|
+
const layers = ((_b = (_a = this.map.getStyle()) === null || _a === void 0 ? void 0 : _a.layers) !== null && _b !== void 0 ? _b : []).filter((layer) => !isCircleLayerId(layer.id));
|
|
880
|
+
if (order === "belowLabels") {
|
|
881
|
+
return (_c = layers.find((layer) => layer.type === "symbol")) === null || _c === void 0 ? void 0 : _c.id;
|
|
882
|
+
}
|
|
883
|
+
// aboveBasemap
|
|
884
|
+
let lastNonSymbolIndex = -1;
|
|
885
|
+
layers.forEach((layer, index) => {
|
|
886
|
+
if (layer.type !== "symbol")
|
|
887
|
+
lastNonSymbolIndex = index;
|
|
888
|
+
});
|
|
889
|
+
return (_d = layers.slice(lastNonSymbolIndex + 1).find((layer) => layer.type === "symbol")) === null || _d === void 0 ? void 0 : _d.id;
|
|
890
|
+
}
|
|
891
|
+
/**
|
|
892
|
+
* Idempotently ensures the shared circle source and one fill/line layer
|
|
893
|
+
* pair per render order in use, at the placement that order requires.
|
|
894
|
+
* Placement is recomputed and re-asserted (via moveLayer) on every call,
|
|
895
|
+
* so circles regain their correct z-order after any style reload or
|
|
896
|
+
* floor/parent-place change. Safe to call at any time: a style that is
|
|
897
|
+
* still loading simply rejects the calls, and the styledata listener
|
|
898
|
+
* retries once the style is ready.
|
|
899
|
+
*/
|
|
817
900
|
ensureCircleLayers() {
|
|
818
|
-
var _a, _b, _c;
|
|
819
901
|
if (!this.map)
|
|
820
902
|
return;
|
|
821
903
|
try {
|
|
@@ -825,31 +907,54 @@ export class InternalMapVXMap extends Loggeable {
|
|
|
825
907
|
data: this.circleFeatureCollection(),
|
|
826
908
|
});
|
|
827
909
|
}
|
|
828
|
-
const
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
const
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
910
|
+
const ordersInUse = new Set(this.circles.map((c) => c.renderOrder));
|
|
911
|
+
// Always keep the default bucket alive so an empty map still renders
|
|
912
|
+
// newly added circles without a layer rebuild
|
|
913
|
+
ordersInUse.add("aboveBasemap");
|
|
914
|
+
// Process buckets lowest-first (CIRCLE_RENDER_ORDERS is canonical):
|
|
915
|
+
// when two buckets resolve to the same anchor, each addLayer/moveLayer
|
|
916
|
+
// lands immediately before it, so a bucket processed later paints above
|
|
917
|
+
// the ones processed earlier. Canonical order keeps
|
|
918
|
+
// belowLabels < aboveBasemap < top regardless of circle insertion order.
|
|
919
|
+
for (const order of CIRCLE_RENDER_ORDERS) {
|
|
920
|
+
if (!ordersInUse.has(order))
|
|
921
|
+
continue;
|
|
922
|
+
const ids = circleLayerIdsFor(order);
|
|
923
|
+
const beforeId = this.circleBeforeIdFor(order);
|
|
924
|
+
const orderFilter = ["==", ["get", "renderOrder"], order];
|
|
925
|
+
if (!this.map.getLayer(ids.fill)) {
|
|
926
|
+
const fillLayer = {
|
|
927
|
+
id: ids.fill,
|
|
928
|
+
type: "fill",
|
|
929
|
+
source: CIRCLE_SOURCE_ID,
|
|
930
|
+
filter: orderFilter,
|
|
931
|
+
paint: {
|
|
932
|
+
"fill-color": ["get", "fillColor"],
|
|
933
|
+
"fill-opacity": ["get", "fillOpacity"],
|
|
934
|
+
},
|
|
935
|
+
};
|
|
936
|
+
this.map.addLayer(fillLayer, beforeId);
|
|
937
|
+
}
|
|
938
|
+
else {
|
|
939
|
+
this.map.moveLayer(ids.fill, beforeId);
|
|
940
|
+
}
|
|
941
|
+
if (!this.map.getLayer(ids.line)) {
|
|
942
|
+
const lineLayer = {
|
|
943
|
+
id: ids.line,
|
|
944
|
+
type: "line",
|
|
945
|
+
source: CIRCLE_SOURCE_ID,
|
|
946
|
+
filter: orderFilter,
|
|
947
|
+
paint: {
|
|
948
|
+
"line-color": ["get", "strokeColor"],
|
|
949
|
+
"line-width": ["get", "strokeWidth"],
|
|
950
|
+
"line-opacity": ["get", "strokeOpacity"],
|
|
951
|
+
},
|
|
952
|
+
};
|
|
953
|
+
this.map.addLayer(lineLayer, beforeId);
|
|
954
|
+
}
|
|
955
|
+
else {
|
|
956
|
+
this.map.moveLayer(ids.line, beforeId);
|
|
957
|
+
}
|
|
853
958
|
}
|
|
854
959
|
}
|
|
855
960
|
catch (error) {
|
|
@@ -993,6 +1098,49 @@ export class InternalMapVXMap extends Loggeable {
|
|
|
993
1098
|
this.map.setMinZoom(zoomLvl);
|
|
994
1099
|
(_a = options === null || options === void 0 ? void 0 : options.onComplete) === null || _a === void 0 ? void 0 : _a.call(options);
|
|
995
1100
|
}
|
|
1101
|
+
setBearing(degrees, options) {
|
|
1102
|
+
var _a;
|
|
1103
|
+
if (!Number.isFinite(degrees))
|
|
1104
|
+
return;
|
|
1105
|
+
if (options === null || options === void 0 ? void 0 : options.animate) {
|
|
1106
|
+
if (options.onComplete)
|
|
1107
|
+
void this.map.once("moveend", options.onComplete);
|
|
1108
|
+
this.map.rotateTo(degrees, { duration: 600 });
|
|
1109
|
+
return;
|
|
1110
|
+
}
|
|
1111
|
+
this.map.setBearing(degrees);
|
|
1112
|
+
(_a = options === null || options === void 0 ? void 0 : options.onComplete) === null || _a === void 0 ? void 0 : _a.call(options);
|
|
1113
|
+
}
|
|
1114
|
+
setRotationEnabled(enabled) {
|
|
1115
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
1116
|
+
if (enabled) {
|
|
1117
|
+
(_b = (_a = this.map.dragRotate) === null || _a === void 0 ? void 0 : _a.enable) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1118
|
+
(_d = (_c = this.map.touchZoomRotate) === null || _c === void 0 ? void 0 : _c.enableRotation) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
1119
|
+
(_f = (_e = this.map.keyboard) === null || _e === void 0 ? void 0 : _e.enable) === null || _f === void 0 ? void 0 : _f.call(_e);
|
|
1120
|
+
}
|
|
1121
|
+
else {
|
|
1122
|
+
(_h = (_g = this.map.dragRotate) === null || _g === void 0 ? void 0 : _g.disable) === null || _h === void 0 ? void 0 : _h.call(_g);
|
|
1123
|
+
(_k = (_j = this.map.touchZoomRotate) === null || _j === void 0 ? void 0 : _j.disableRotation) === null || _k === void 0 ? void 0 : _k.call(_j);
|
|
1124
|
+
}
|
|
1125
|
+
}
|
|
1126
|
+
setPanEnabled(enabled) {
|
|
1127
|
+
var _a, _b, _c, _d;
|
|
1128
|
+
if (enabled) {
|
|
1129
|
+
(_b = (_a = this.map.dragPan) === null || _a === void 0 ? void 0 : _a.enable) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1130
|
+
}
|
|
1131
|
+
else {
|
|
1132
|
+
(_d = (_c = this.map.dragPan) === null || _c === void 0 ? void 0 : _c.disable) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
setScrollZoomEnabled(enabled) {
|
|
1136
|
+
var _a, _b, _c, _d;
|
|
1137
|
+
if (enabled) {
|
|
1138
|
+
(_b = (_a = this.map.scrollZoom) === null || _a === void 0 ? void 0 : _a.enable) === null || _b === void 0 ? void 0 : _b.call(_a);
|
|
1139
|
+
}
|
|
1140
|
+
else {
|
|
1141
|
+
(_d = (_c = this.map.scrollZoom) === null || _c === void 0 ? void 0 : _c.disable) === null || _d === void 0 ? void 0 : _d.call(_c);
|
|
1142
|
+
}
|
|
1143
|
+
}
|
|
996
1144
|
isInsideBounds(point) {
|
|
997
1145
|
const mapBounds = this.map.getMaxBounds();
|
|
998
1146
|
if (mapBounds != null) {
|
|
@@ -1161,7 +1309,7 @@ export class InternalMapVXMap extends Loggeable {
|
|
|
1161
1309
|
if (pointedPlace !== undefined) {
|
|
1162
1310
|
new maplibregl.Popup()
|
|
1163
1311
|
.setLngLat(pointedPlace.position)
|
|
1164
|
-
.
|
|
1312
|
+
.setText(pointedPlace.title)
|
|
1165
1313
|
.addTo(this.map);
|
|
1166
1314
|
}
|
|
1167
1315
|
}
|