@mapvx/web-components 0.0.26 → 0.0.28
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 +16 -3
- package/dist/cjs/{base-floor-selector-Bm8sTYdJ.cjs → base-floor-selector-B3a-e0nh.cjs} +2 -2
- package/dist/cjs/{class-map-BYn-9uvy.cjs → class-map-CIXsqmkI.cjs} +2 -2
- package/dist/cjs/{compact-floor-selector-DhhESOe0.cjs → compact-floor-selector-DH5p6Akw.cjs} +2 -2
- package/dist/cjs/{consume-BE7YStBl.cjs → consume-DbQgH4p2.cjs} +2 -2
- package/dist/cjs/custom-map-BNkNKDPg.cjs +97 -0
- package/dist/cjs/{floor-selector-C27g9abV.cjs → floor-selector-BnDHhgRH.cjs} +2 -2
- package/dist/cjs/{lazy-load-CES1Ya_D.cjs → lazy-load-D1GQGqJ4.cjs} +2 -2
- package/dist/cjs/map-view-with-modal.cjs +6 -6
- package/dist/cjs/{qr-modal-BQG75u-x.cjs → qr-modal-DqYNHVOp.cjs} +2 -2
- package/dist/cjs/{route-options-C09f-35r.cjs → route-options-DlRssN7i.cjs} +2 -2
- package/dist/cjs/route-view-totems.cjs +3 -3
- package/dist/components/custom-map.d.ts +13 -0
- package/dist/components/custom-map.js +64 -0
- package/dist/components/floor-selector.d.ts +6 -0
- package/dist/components/floor-selector.js +40 -0
- package/dist/components/qr-modal.d.ts +7 -0
- package/dist/components/qr-modal.js +69 -0
- package/dist/components/route-options.d.ts +6 -0
- package/dist/components/route-options.js +51 -0
- package/dist/components/zoom-controls.d.ts +6 -0
- package/dist/components/zoom-controls.js +40 -0
- package/dist/es/assets/{compact-floor-selector-D-822e0L.js → compact-floor-selector-COkSgy5C.js} +3 -3
- package/dist/es/assets/{components-B6oTyj0x.js → components-Hs2pRrmU.js} +55 -13
- package/dist/es/assets/{map-view-with-modal-DfkRlpPp.js → map-view-with-modal-dYGc6zQN.js} +46 -4
- package/dist/es/assets/{route-view-totems-BWtwjegR.js → route-view-totems-DdSI5H8D.js} +57 -9
- package/dist/es/assets/{utils-EeRdvb4i.js → utils-Fh1PwBJP.js} +117 -28
- package/dist/es/index.js +2 -2
- package/dist/es/route-view-totems.js +2 -2
- package/dist/iife/map-view-with-modal.js +2 -2
- package/dist/iife/route-view-totems.js +3 -3
- package/dist/route-view-totems.d.ts +16 -0
- package/dist/route-view-totems.js +58 -0
- package/dist/sw/mvx-tiles-sw.js +63 -0
- package/dist/utils/styles.d.ts +2 -0
- package/dist/utils/styles.js +5 -0
- package/package.json +4 -3
- package/dist/cjs/custom-map-03ak_Vof.cjs +0 -97
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as i$2, x, r, i as i$3, t as t$1, T } from './route-view-totems-
|
|
2
|
-
import { R as RouteAnimationController, M as MarkerController } from './utils-
|
|
1
|
+
import { a as i$2, x, r, i as i$3, t as t$1, T } from './route-view-totems-DdSI5H8D.js';
|
|
2
|
+
import { R as RouteAnimationController, M as MarkerController } from './utils-Fh1PwBJP.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @license
|
|
@@ -121,11 +121,12 @@ let CustomMap = class extends i$2 {
|
|
|
121
121
|
if (!this.lzMap && sdk && parentPlace && locale && this.shadowRoot && generalConfig) {
|
|
122
122
|
this.routeAnimationController.setParentPlace(parentPlace);
|
|
123
123
|
this.routeAnimationController.setLocale(locale);
|
|
124
|
+
this.routeAnimationController.setConfig(generalConfig);
|
|
124
125
|
this.mapContainer = this.shadowRoot.getElementById("map");
|
|
125
126
|
this.shadowRoot?.appendChild(this.mapContainer);
|
|
126
127
|
this.config = generalConfig;
|
|
127
128
|
const mapConfig = {
|
|
128
|
-
zoom: generalConfig.initialZoom ||
|
|
129
|
+
zoom: generalConfig.initialZoom || 18,
|
|
129
130
|
parentPlaceId: parentPlace?.lazarilloId,
|
|
130
131
|
center: generalConfig.initialCenter || { lat: 0, lng: 0 },
|
|
131
132
|
minZoom: generalConfig.limitZoomOut || 15,
|
|
@@ -157,6 +158,7 @@ let CustomMap = class extends i$2 {
|
|
|
157
158
|
this.routeAnimationController.setMap(this.lzMap);
|
|
158
159
|
this.markerController.setMap(this.lzMap);
|
|
159
160
|
this.markerController.setParentPlace(parentPlace);
|
|
161
|
+
this.markerController.setConfig(generalConfig);
|
|
160
162
|
}
|
|
161
163
|
if (currentFloor && currentFloor.key !== this._currentMapFloor && this.mapReady) {
|
|
162
164
|
this.setCurrentMapFloor(currentFloor.key);
|
|
@@ -195,15 +197,55 @@ let CustomMap = class extends i$2 {
|
|
|
195
197
|
}
|
|
196
198
|
_initializeCamera() {
|
|
197
199
|
if (!this.lzMap || !this.mapReady || !this.sdkData) return;
|
|
198
|
-
const { destination, origin } = this.sdkData;
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
200
|
+
const { destination, origin, route } = this.sdkData;
|
|
201
|
+
if (!route) {
|
|
202
|
+
const center = destination ? destination.position : origin?.position;
|
|
203
|
+
this.lzMap?.updateCamera({
|
|
204
|
+
bearing: this.config?.mapRotations?.[origin?.lazarilloId ?? ""]?.angle ?? 0,
|
|
205
|
+
animate: false,
|
|
206
|
+
pitch: this.config?.pitch ?? 0,
|
|
207
|
+
center,
|
|
208
|
+
zoom: 20.5
|
|
209
|
+
// zoom: this.config?.initialZoom ?? 18,
|
|
210
|
+
});
|
|
211
|
+
} else {
|
|
212
|
+
const originFloor = origin?.inFloors?.[0];
|
|
213
|
+
if (originFloor && route.legs) {
|
|
214
|
+
const routeCoordinates = route.legs.flatMap((leg) => leg.steps).filter((step) => step.startInsideFloor === originFloor || step.endInsideFloor === originFloor).flatMap((step) => step.coordinates);
|
|
215
|
+
if (routeCoordinates.length > 0) {
|
|
216
|
+
setTimeout(() => {
|
|
217
|
+
this.lzMap?.fitCoordinates(routeCoordinates, {
|
|
218
|
+
padding: {
|
|
219
|
+
top: 200,
|
|
220
|
+
bottom: 200,
|
|
221
|
+
left: 200,
|
|
222
|
+
right: 200
|
|
223
|
+
}
|
|
224
|
+
});
|
|
225
|
+
}, 200);
|
|
226
|
+
} else {
|
|
227
|
+
const center = destination ? destination.position : origin?.position;
|
|
228
|
+
this.lzMap?.updateCamera({
|
|
229
|
+
bearing: this.config?.mapRotations?.[origin?.lazarilloId ?? ""]?.angle ?? 0,
|
|
230
|
+
animate: false,
|
|
231
|
+
pitch: this.config?.pitch ?? 0,
|
|
232
|
+
center,
|
|
233
|
+
zoom: 20.5
|
|
234
|
+
// zoom: this.config?.initialZoom ?? 18,
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
} else {
|
|
238
|
+
const center = destination ? destination.position : origin?.position;
|
|
239
|
+
this.lzMap?.updateCamera({
|
|
240
|
+
bearing: this.config?.mapRotations?.[origin?.lazarilloId ?? ""]?.angle ?? 0,
|
|
241
|
+
animate: false,
|
|
242
|
+
pitch: this.config?.pitch ?? 0,
|
|
243
|
+
center,
|
|
244
|
+
zoom: 20.5
|
|
245
|
+
// zoom: this.config?.initialZoom ?? 18,
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
}
|
|
207
249
|
const floor = destination?.inFloors?.[0];
|
|
208
250
|
if (floor) {
|
|
209
251
|
this.lzMap?.updateFloor(floor);
|
|
@@ -3787,4 +3829,4 @@ const routeOptions = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProper
|
|
|
3787
3829
|
}, Symbol.toStringTag, { value: 'Module' }));
|
|
3788
3830
|
|
|
3789
3831
|
export { BaseFloorSelector as B, customMap as c, e, floorSelector as f, i$1 as i, qrModal as q, routeOptions as r, sdkContext as s };
|
|
3790
|
-
//# sourceMappingURL=components-
|
|
3832
|
+
//# sourceMappingURL=components-Hs2pRrmU.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i, n, a as i$1, A as AnalyticsController, l as loadCustomMap, b as loadCompactFloorSelector, R as RollbarController, x, t } from './route-view-totems-
|
|
2
|
-
import { S as SDKController } from './utils-
|
|
1
|
+
import { i, n, a as i$1, A as AnalyticsController, l as loadCustomMap, b as loadCompactFloorSelector, p as preloadMaplibreCss, R as RollbarController, x, t } from './route-view-totems-DdSI5H8D.js';
|
|
2
|
+
import { S as SDKController } from './utils-Fh1PwBJP.js';
|
|
3
3
|
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
5
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -31,6 +31,8 @@ let MapViewWithModal = class extends i$1 {
|
|
|
31
31
|
__privateAdd(this, _showFloorSelector, true);
|
|
32
32
|
__privateAdd(this, _floorSelectorPosition, "top-left");
|
|
33
33
|
__privateAdd(this, _floorSelectorDisabled, false);
|
|
34
|
+
this._swPath = "/mvx-tiles-sw.js";
|
|
35
|
+
this._swScope = "/";
|
|
34
36
|
this.sdkController = new SDKController(this);
|
|
35
37
|
this.analyticsController = AnalyticsController.getInstance();
|
|
36
38
|
this.currentFloorId = "";
|
|
@@ -92,8 +94,44 @@ let MapViewWithModal = class extends i$1 {
|
|
|
92
94
|
async _loadComponents() {
|
|
93
95
|
await Promise.all([loadCustomMap(), loadCompactFloorSelector()]);
|
|
94
96
|
}
|
|
97
|
+
_preloadApiRequests() {
|
|
98
|
+
const token = this.apiKey || this.getAttribute("apiKey") || "";
|
|
99
|
+
const parent = this.parentPlaceId || this.getAttribute("parentPlaceId") || "";
|
|
100
|
+
const lang = this.locale || this.getAttribute("locale") || "es";
|
|
101
|
+
if (!token || !parent) return;
|
|
102
|
+
const addPreload = (url) => {
|
|
103
|
+
const key = `mvx-preload:${url}`;
|
|
104
|
+
if (document.head.querySelector(`link[data-mvx-preload="${key}"]`)) return;
|
|
105
|
+
const link = document.createElement("link");
|
|
106
|
+
link.rel = "preload";
|
|
107
|
+
link.as = "fetch";
|
|
108
|
+
link.href = url;
|
|
109
|
+
link.crossOrigin = "anonymous";
|
|
110
|
+
link.setAttribute("fetchpriority", "high");
|
|
111
|
+
link.setAttribute("data-mvx-preload", key);
|
|
112
|
+
document.head.appendChild(link);
|
|
113
|
+
};
|
|
114
|
+
const baseSDK = "https://api.mapvx.com/sdk/";
|
|
115
|
+
const baseAPI = "https://api.mapvx.com/api/";
|
|
116
|
+
const enc = encodeURIComponent;
|
|
117
|
+
addPreload(`${baseSDK}v3/place?token=${enc(token)}&place_id=${enc(parent)}&lang=${enc(lang)}`);
|
|
118
|
+
addPreload(`${baseAPI}configuration?token=${enc(token)}&lang=${enc(lang)}&place_id=${enc(parent)}`);
|
|
119
|
+
if (this.placeId) {
|
|
120
|
+
addPreload(`${baseSDK}v3/place?token=${enc(token)}&place_id=${enc(this.placeId)}&lang=${enc(lang)}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
async _registerTileCacheSW() {
|
|
124
|
+
if (!("serviceWorker" in navigator)) return;
|
|
125
|
+
try {
|
|
126
|
+
await navigator.serviceWorker.register(this._swPath, { scope: this._swScope });
|
|
127
|
+
} catch {
|
|
128
|
+
}
|
|
129
|
+
}
|
|
95
130
|
async firstUpdated() {
|
|
96
|
-
|
|
131
|
+
void this._registerTileCacheSW();
|
|
132
|
+
const componentsPromise = this._loadComponents();
|
|
133
|
+
const cssPromise = preloadMaplibreCss();
|
|
134
|
+
await Promise.all([componentsPromise, cssPromise]);
|
|
97
135
|
{
|
|
98
136
|
this.analyticsController.initialize("map-view-with-modal");
|
|
99
137
|
RollbarController.initialize("map-view-with-modal");
|
|
@@ -148,6 +186,10 @@ let MapViewWithModal = class extends i$1 {
|
|
|
148
186
|
}
|
|
149
187
|
updated(changedProperties) {
|
|
150
188
|
if (this.apiKey && this.locale && this.parentPlaceId && (changedProperties.has("apiKey") || changedProperties.has("locale") || changedProperties.has("parentPlaceId"))) {
|
|
189
|
+
this._preloadApiRequests();
|
|
190
|
+
this.sdkController.prewarm(this.apiKey, this.locale, this.parentPlaceId, {
|
|
191
|
+
destinationId: this.placeId
|
|
192
|
+
});
|
|
151
193
|
this.sdkController.initialize(this.apiKey, this.locale, this.parentPlaceId);
|
|
152
194
|
}
|
|
153
195
|
if (this.placeId && changedProperties.has("placeId")) {
|
|
@@ -279,4 +321,4 @@ MapViewWithModal = __decorateClass([
|
|
|
279
321
|
], MapViewWithModal);
|
|
280
322
|
|
|
281
323
|
export { MapViewWithModal as M };
|
|
282
|
-
//# sourceMappingURL=map-view-with-modal-
|
|
324
|
+
//# sourceMappingURL=map-view-with-modal-dYGc6zQN.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as SDKController } from './utils-
|
|
1
|
+
import { S as SDKController } from './utils-Fh1PwBJP.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* @license
|
|
@@ -184,11 +184,17 @@ class AnalyticsController {
|
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
const loadCustomMap = () => import('./components-
|
|
188
|
-
const loadFloorSelector = () => import('./components-
|
|
189
|
-
const loadCompactFloorSelector = () => import('./compact-floor-selector-
|
|
190
|
-
const loadQrModal = () => import('./components-
|
|
191
|
-
const loadRouteOptions = () => import('./components-
|
|
187
|
+
const loadCustomMap = () => import('./components-Hs2pRrmU.js').then(n => n.c);
|
|
188
|
+
const loadFloorSelector = () => import('./components-Hs2pRrmU.js').then(n => n.f);
|
|
189
|
+
const loadCompactFloorSelector = () => import('./compact-floor-selector-COkSgy5C.js');
|
|
190
|
+
const loadQrModal = () => import('./components-Hs2pRrmU.js').then(n => n.q);
|
|
191
|
+
const loadRouteOptions = () => import('./components-Hs2pRrmU.js').then(n => n.r);
|
|
192
|
+
const preloadMaplibreCss = async () => {
|
|
193
|
+
try {
|
|
194
|
+
await import('./maplibre-gl-BKzNcqp_.js');
|
|
195
|
+
} catch {
|
|
196
|
+
}
|
|
197
|
+
};
|
|
192
198
|
|
|
193
199
|
var __defProp = Object.defineProperty;
|
|
194
200
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -241,6 +247,8 @@ let RouteViewTotems = class extends i {
|
|
|
241
247
|
__privateAdd(this, _locale, "es");
|
|
242
248
|
__privateAdd(this, _originId, "");
|
|
243
249
|
__privateAdd(this, _destinationId, "");
|
|
250
|
+
this._swPath = "/mvx-tiles-sw.js";
|
|
251
|
+
this._swScope = "/";
|
|
244
252
|
this.sdkController = new SDKController(this);
|
|
245
253
|
this.analyticsController = AnalyticsController.getInstance();
|
|
246
254
|
}
|
|
@@ -277,8 +285,43 @@ let RouteViewTotems = class extends i {
|
|
|
277
285
|
async _loadComponents() {
|
|
278
286
|
await Promise.all([loadCustomMap(), loadFloorSelector(), loadQrModal(), loadRouteOptions()]);
|
|
279
287
|
}
|
|
288
|
+
_preloadApiRequests() {
|
|
289
|
+
const token = this.apiKey || this.getAttribute("apiKey") || "";
|
|
290
|
+
const parent = this.parentPlaceId || this.getAttribute("parentPlaceId") || "";
|
|
291
|
+
const lang = this.locale || this.getAttribute("locale") || "es";
|
|
292
|
+
if (!token || !parent) return;
|
|
293
|
+
const addPreload = (url) => {
|
|
294
|
+
const key = `mvx-preload:${url}`;
|
|
295
|
+
if (document.head.querySelector(`link[data-mvx-preload="${key}"]`)) return;
|
|
296
|
+
const link = document.createElement("link");
|
|
297
|
+
link.rel = "preload";
|
|
298
|
+
link.as = "fetch";
|
|
299
|
+
link.href = url;
|
|
300
|
+
link.crossOrigin = "anonymous";
|
|
301
|
+
link.setAttribute("fetchpriority", "high");
|
|
302
|
+
link.setAttribute("data-mvx-preload", key);
|
|
303
|
+
document.head.appendChild(link);
|
|
304
|
+
};
|
|
305
|
+
const baseSDK = "https://api.mapvx.com/sdk/";
|
|
306
|
+
const baseAPI = "https://api.mapvx.com/api/";
|
|
307
|
+
const enc = encodeURIComponent;
|
|
308
|
+
addPreload(`${baseSDK}v3/place?token=${enc(token)}&place_id=${enc(parent)}&lang=${enc(lang)}`);
|
|
309
|
+
addPreload(`${baseAPI}configuration?token=${enc(token)}&lang=${enc(lang)}&place_id=${enc(parent)}`);
|
|
310
|
+
if (this.originId) {
|
|
311
|
+
addPreload(`${baseSDK}v3/place?token=${enc(token)}&place_id=${enc(this.originId)}&lang=${enc(lang)}`);
|
|
312
|
+
}
|
|
313
|
+
if (this.destinationId) {
|
|
314
|
+
addPreload(`${baseSDK}v3/place?token=${enc(token)}&place_id=${enc(this.destinationId)}&lang=${enc(lang)}`);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
280
317
|
async firstUpdated() {
|
|
281
|
-
|
|
318
|
+
if ("serviceWorker" in navigator) {
|
|
319
|
+
navigator.serviceWorker.register(this._swPath, { scope: this._swScope }).catch(() => {
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
const componentsPromise = this._loadComponents();
|
|
323
|
+
const cssPromise = preloadMaplibreCss();
|
|
324
|
+
await Promise.all([componentsPromise, cssPromise]);
|
|
282
325
|
{
|
|
283
326
|
this.analyticsController.initialize("route-view-totems");
|
|
284
327
|
RollbarController.initialize("route-view-totems");
|
|
@@ -318,6 +361,11 @@ let RouteViewTotems = class extends i {
|
|
|
318
361
|
}
|
|
319
362
|
updated(changedProperties) {
|
|
320
363
|
if (this.apiKey && this.locale && this.parentPlaceId && (changedProperties.has("apiKey") || changedProperties.has("locale") || changedProperties.has("parentPlaceId"))) {
|
|
364
|
+
this._preloadApiRequests();
|
|
365
|
+
this.sdkController.prewarm(this.apiKey, this.locale, this.parentPlaceId, {
|
|
366
|
+
originId: this.originId,
|
|
367
|
+
destinationId: this.destinationId
|
|
368
|
+
});
|
|
321
369
|
this.sdkController.initialize(this.apiKey, this.locale, this.parentPlaceId);
|
|
322
370
|
}
|
|
323
371
|
if (this.originId && changedProperties.has("destinationId")) {
|
|
@@ -417,5 +465,5 @@ RouteViewTotems = __decorateClass([
|
|
|
417
465
|
t("route-view-totems")
|
|
418
466
|
], RouteViewTotems);
|
|
419
467
|
|
|
420
|
-
export { AnalyticsController as A, RollbarController as R, T, i as a, loadCompactFloorSelector as b, RouteViewTotems as c, i$3 as i, loadCustomMap as l, n, r$3 as r, t, x };
|
|
421
|
-
//# sourceMappingURL=route-view-totems-
|
|
468
|
+
export { AnalyticsController as A, RollbarController as R, T, i as a, loadCompactFloorSelector as b, RouteViewTotems as c, i$3 as i, loadCustomMap as l, n, preloadMaplibreCss as p, r$3 as r, t, x };
|
|
469
|
+
//# sourceMappingURL=route-view-totems-DdSI5H8D.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i, s as sdkContext } from './components-
|
|
2
|
-
import { R as RollbarController } from './route-view-totems-
|
|
1
|
+
import { i, s as sdkContext } from './components-Hs2pRrmU.js';
|
|
2
|
+
import { R as RollbarController } from './route-view-totems-DdSI5H8D.js';
|
|
3
3
|
|
|
4
4
|
var dist = {exports: {}};
|
|
5
5
|
|
|
@@ -12356,8 +12356,75 @@ class SDKController {
|
|
|
12356
12356
|
initialValue: { enabledFloors: [], markers: [], cameraInitialized: false }
|
|
12357
12357
|
});
|
|
12358
12358
|
}
|
|
12359
|
+
/**
|
|
12360
|
+
* Prewarm SDK and fetch critical data in parallel to reduce first render time.
|
|
12361
|
+
* If origin/destination are provided, their details will also be prefetched and markers/floor set accordingly.
|
|
12362
|
+
*/
|
|
12363
|
+
async prewarm(apiKey, locale, parentPlaceId, options) {
|
|
12364
|
+
if (!this.connected) return;
|
|
12365
|
+
const sdk = distExports.initializeSDK(apiKey, { lang: locale });
|
|
12366
|
+
this.contextProvider.setValue({
|
|
12367
|
+
...this.contextProvider.value,
|
|
12368
|
+
sdk,
|
|
12369
|
+
locale,
|
|
12370
|
+
parentPlaceId,
|
|
12371
|
+
originId: options?.originId ?? this.contextProvider.value.originId,
|
|
12372
|
+
destinationId: options?.destinationId ?? this.contextProvider.value.destinationId
|
|
12373
|
+
});
|
|
12374
|
+
try {
|
|
12375
|
+
const [config, parentPlace, origin, destination] = await Promise.all([
|
|
12376
|
+
sdk.getConfiguration(parentPlaceId).catch(() => void 0),
|
|
12377
|
+
sdk.getPlaceDetail(parentPlaceId).catch(() => void 0),
|
|
12378
|
+
options?.originId ? sdk.getPlaceDetail(options.originId).catch(() => void 0) : Promise.resolve(void 0),
|
|
12379
|
+
options?.destinationId ? sdk.getPlaceDetail(options.destinationId).catch(() => void 0) : Promise.resolve(void 0)
|
|
12380
|
+
]);
|
|
12381
|
+
const parentFloors = parentPlace?.innerFloors || [];
|
|
12382
|
+
let enabledFloors = parentFloors;
|
|
12383
|
+
let currentFloor = void 0;
|
|
12384
|
+
if (origin || destination) {
|
|
12385
|
+
const floors = [origin, destination].map((place) => place?.inFloor(parentFloors)).filter((floor) => floor !== void 0);
|
|
12386
|
+
if (floors.length > 0) {
|
|
12387
|
+
enabledFloors = floors;
|
|
12388
|
+
}
|
|
12389
|
+
currentFloor = destination?.inFloors?.[0] ? parentFloors.find((f) => f.key === destination.inFloors[0]) : origin?.inFloors?.[0] ? parentFloors.find((f) => f.key === origin.inFloors[0]) : void 0;
|
|
12390
|
+
}
|
|
12391
|
+
this.enabledFloors = enabledFloors;
|
|
12392
|
+
this.contextProvider.setValue({
|
|
12393
|
+
...this.contextProvider.value,
|
|
12394
|
+
generalConfig: config ?? this.contextProvider.value.generalConfig,
|
|
12395
|
+
parentPlace: parentPlace ?? this.contextProvider.value.parentPlace,
|
|
12396
|
+
origin: origin ?? this.contextProvider.value.origin,
|
|
12397
|
+
destination: destination ?? this.contextProvider.value.destination,
|
|
12398
|
+
enabledFloors,
|
|
12399
|
+
currentFloor: currentFloor ?? this.contextProvider.value.currentFloor,
|
|
12400
|
+
// Pre-create markers if we have origin/destination
|
|
12401
|
+
markers: [
|
|
12402
|
+
...origin ? [
|
|
12403
|
+
{
|
|
12404
|
+
id: origin.lazarilloId,
|
|
12405
|
+
data: origin,
|
|
12406
|
+
style: MarkerStyle.youAreHere
|
|
12407
|
+
}
|
|
12408
|
+
] : [],
|
|
12409
|
+
...destination ? [
|
|
12410
|
+
{
|
|
12411
|
+
id: destination.lazarilloId,
|
|
12412
|
+
data: destination,
|
|
12413
|
+
style: MarkerStyle.placePopup
|
|
12414
|
+
}
|
|
12415
|
+
] : []
|
|
12416
|
+
]
|
|
12417
|
+
});
|
|
12418
|
+
} catch (error) {
|
|
12419
|
+
RollbarController.getInstance().warning("Error prewarming SDK", { error, parentPlaceId });
|
|
12420
|
+
}
|
|
12421
|
+
}
|
|
12359
12422
|
initialize(apiKey, locale, parentPlaceId) {
|
|
12360
12423
|
if (!this.connected) return;
|
|
12424
|
+
const current = this.contextProvider.value;
|
|
12425
|
+
if (current.sdk && current.locale === locale && current.parentPlaceId === parentPlaceId) {
|
|
12426
|
+
return;
|
|
12427
|
+
}
|
|
12361
12428
|
this.initializeSDK(apiKey, locale, parentPlaceId);
|
|
12362
12429
|
const { originId, destinationId } = this.contextProvider.value;
|
|
12363
12430
|
if (originId && destinationId) {
|
|
@@ -12390,9 +12457,9 @@ class SDKController {
|
|
|
12390
12457
|
destination
|
|
12391
12458
|
});
|
|
12392
12459
|
this.createOriginDestinationMarkers(origin, destination);
|
|
12393
|
-
const
|
|
12394
|
-
if (
|
|
12395
|
-
this.setFloor(
|
|
12460
|
+
const currentFloorId = destination?.inFloors?.[0] || origin?.inFloors?.[0];
|
|
12461
|
+
if (currentFloorId) {
|
|
12462
|
+
this.setFloor(currentFloorId);
|
|
12396
12463
|
}
|
|
12397
12464
|
const parentFloors = this.contextProvider.value.parentPlace?.innerFloors || [];
|
|
12398
12465
|
const enabledFloors = [origin, destination].filter((p) => !!p).map((place) => place.inFloor(parentFloors)).filter((floor) => floor !== void 0);
|
|
@@ -12463,14 +12530,12 @@ class SDKController {
|
|
|
12463
12530
|
parentPlaceId
|
|
12464
12531
|
});
|
|
12465
12532
|
try {
|
|
12466
|
-
await
|
|
12467
|
-
|
|
12468
|
-
|
|
12469
|
-
|
|
12470
|
-
try {
|
|
12471
|
-
const parentPlace = await sdk.getPlaceDetail(parentPlaceId);
|
|
12533
|
+
const [config, parentPlace] = await Promise.all([
|
|
12534
|
+
sdk.getConfiguration(parentPlaceId).catch(() => void 0),
|
|
12535
|
+
sdk.getPlaceDetail(parentPlaceId).catch(() => void 0)
|
|
12536
|
+
]);
|
|
12472
12537
|
const { origin, destination } = this.contextProvider.value;
|
|
12473
|
-
let enabledFloors = parentPlace
|
|
12538
|
+
let enabledFloors = parentPlace?.innerFloors || [];
|
|
12474
12539
|
const currentFloor = origin?.inFloor(enabledFloors) || destination?.inFloor(enabledFloors);
|
|
12475
12540
|
if (origin || destination) {
|
|
12476
12541
|
enabledFloors = [origin, destination].map((place) => place?.inFloor(enabledFloors)).filter((floor) => floor !== void 0);
|
|
@@ -12478,7 +12543,8 @@ class SDKController {
|
|
|
12478
12543
|
}
|
|
12479
12544
|
this.contextProvider.setValue({
|
|
12480
12545
|
...this.contextProvider.value,
|
|
12481
|
-
|
|
12546
|
+
generalConfig: config ?? this.contextProvider.value.generalConfig,
|
|
12547
|
+
parentPlace: parentPlace ?? this.contextProvider.value.parentPlace,
|
|
12482
12548
|
enabledFloors,
|
|
12483
12549
|
currentFloor
|
|
12484
12550
|
});
|
|
@@ -12648,9 +12714,11 @@ class MarkerController {
|
|
|
12648
12714
|
setParentPlace(place) {
|
|
12649
12715
|
this.parentPlace = place;
|
|
12650
12716
|
}
|
|
12717
|
+
setConfig(config) {
|
|
12718
|
+
this.config = config;
|
|
12719
|
+
}
|
|
12651
12720
|
updateMarkers(markers) {
|
|
12652
12721
|
if (!this.connected || !this.map || !this.mapReady || !this.parentPlace) return;
|
|
12653
|
-
const floors = this.parentPlace.innerFloors ?? [];
|
|
12654
12722
|
this.markersIds.forEach((m) => {
|
|
12655
12723
|
try {
|
|
12656
12724
|
this.map?.removeMarker(m.id);
|
|
@@ -12667,7 +12735,7 @@ class MarkerController {
|
|
|
12667
12735
|
case MarkerStyle.youAreHere: {
|
|
12668
12736
|
const markerIcon = document.createElement("img");
|
|
12669
12737
|
const place = data;
|
|
12670
|
-
floorId = place.
|
|
12738
|
+
floorId = place.inFloors?.[0];
|
|
12671
12739
|
markerIcon.src = this.accessibleRoute ? accessibleMarker : walkingMarker;
|
|
12672
12740
|
markerElement = markerIcon;
|
|
12673
12741
|
coordinate = place.position;
|
|
@@ -12721,8 +12789,9 @@ class MarkerController {
|
|
|
12721
12789
|
content.category = "";
|
|
12722
12790
|
}
|
|
12723
12791
|
content.position = data.position;
|
|
12724
|
-
floorId = data.
|
|
12792
|
+
content.floorId = data.inFloors?.[0];
|
|
12725
12793
|
}
|
|
12794
|
+
floorId = content.floorId;
|
|
12726
12795
|
markerElement = PopupFactory.create({
|
|
12727
12796
|
name: content.name,
|
|
12728
12797
|
category: content.category,
|
|
@@ -12754,16 +12823,34 @@ class MarkerController {
|
|
|
12754
12823
|
);
|
|
12755
12824
|
const currentFloor = this.map?.getCurrentFloor();
|
|
12756
12825
|
const coordinates = this.markersIds.filter((m) => m.floorId === currentFloor).map((m) => m.coordinate);
|
|
12757
|
-
if (coordinates.length
|
|
12826
|
+
if (coordinates.length === 1) {
|
|
12827
|
+
setTimeout(() => {
|
|
12828
|
+
this.map?.updateCamera({
|
|
12829
|
+
center: coordinates[0],
|
|
12830
|
+
bearing: this.config?.mapRotations?.[this.parentPlace?.lazarilloId ?? ""]?.angle ?? 0,
|
|
12831
|
+
pitch: this.config?.pitch ?? 0,
|
|
12832
|
+
zoom: 20.5,
|
|
12833
|
+
// zoom: this.config?.initialZoom ?? 18,
|
|
12834
|
+
animate: true
|
|
12835
|
+
});
|
|
12836
|
+
}, 200);
|
|
12837
|
+
} else if (coordinates.length > 0) {
|
|
12758
12838
|
setTimeout(() => {
|
|
12759
12839
|
this.map?.fitCoordinates(coordinates, {
|
|
12760
12840
|
padding: {
|
|
12761
|
-
top:
|
|
12762
|
-
bottom:
|
|
12763
|
-
left:
|
|
12764
|
-
right:
|
|
12841
|
+
top: 200,
|
|
12842
|
+
bottom: 200,
|
|
12843
|
+
left: 200,
|
|
12844
|
+
right: 200
|
|
12765
12845
|
}
|
|
12766
12846
|
});
|
|
12847
|
+
this.map?.updateCamera({
|
|
12848
|
+
bearing: this.config?.mapRotations?.[this.parentPlace?.lazarilloId ?? ""]?.angle ?? 0,
|
|
12849
|
+
pitch: this.config?.pitch ?? 0,
|
|
12850
|
+
zoom: 20.5,
|
|
12851
|
+
// zoom: Math.min(this.config?.initialZoom ?? 18, this.map?.map.getZoom() ?? 18),
|
|
12852
|
+
animate: true
|
|
12853
|
+
});
|
|
12767
12854
|
}, 200);
|
|
12768
12855
|
}
|
|
12769
12856
|
}
|
|
@@ -12808,10 +12895,10 @@ class RouteAnimationController {
|
|
|
12808
12895
|
if (coordinates.length > 0) {
|
|
12809
12896
|
this.lzMap?.fitCoordinates(coordinates, {
|
|
12810
12897
|
padding: {
|
|
12811
|
-
bottom:
|
|
12812
|
-
left:
|
|
12813
|
-
right:
|
|
12814
|
-
top:
|
|
12898
|
+
bottom: 200,
|
|
12899
|
+
left: 350,
|
|
12900
|
+
right: 350,
|
|
12901
|
+
top: 200
|
|
12815
12902
|
}
|
|
12816
12903
|
});
|
|
12817
12904
|
}
|
|
@@ -12823,14 +12910,17 @@ class RouteAnimationController {
|
|
|
12823
12910
|
setLocale(locale) {
|
|
12824
12911
|
this.locale = locale;
|
|
12825
12912
|
}
|
|
12913
|
+
setConfig(config) {
|
|
12914
|
+
this.config = config;
|
|
12915
|
+
}
|
|
12826
12916
|
startRouteAnimation(route) {
|
|
12827
12917
|
if (!this.connected || !this.lzMap || this.isAnimatingRoute) return;
|
|
12828
12918
|
this.isAnimatingRoute = true;
|
|
12829
12919
|
this.stepAnimationDate = /* @__PURE__ */ new Date();
|
|
12920
|
+
this.route = route;
|
|
12830
12921
|
const animationConfig = {
|
|
12831
12922
|
minimumSpeed: 20,
|
|
12832
12923
|
callBack: (status) => {
|
|
12833
|
-
this.stepAnimationDate = /* @__PURE__ */ new Date();
|
|
12834
12924
|
if (status.isFinished) {
|
|
12835
12925
|
this.stopAnimatedRoute();
|
|
12836
12926
|
this.handlers.onRouteAnimationFinished();
|
|
@@ -12886,7 +12976,6 @@ class RouteAnimationController {
|
|
|
12886
12976
|
this.setCurrentFloor(firstFloor);
|
|
12887
12977
|
}
|
|
12888
12978
|
this.lzMap.startAnimateRouteV2(route, drawingConfig, animationConfig);
|
|
12889
|
-
this.route = route;
|
|
12890
12979
|
this.handlers.onStartRouteAnimation();
|
|
12891
12980
|
}
|
|
12892
12981
|
removeRoute() {
|
|
@@ -12950,4 +13039,4 @@ class RouteAnimationController {
|
|
|
12950
13039
|
}
|
|
12951
13040
|
|
|
12952
13041
|
export { MarkerController as M, RouteAnimationController as R, SDKController as S };
|
|
12953
|
-
//# sourceMappingURL=utils-
|
|
13042
|
+
//# sourceMappingURL=utils-Fh1PwBJP.js.map
|
package/dist/es/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { c as RouteViewTotems } from './assets/route-view-totems-
|
|
2
|
-
export { M as MapViewWithModal } from './assets/map-view-with-modal-
|
|
1
|
+
export { c as RouteViewTotems } from './assets/route-view-totems-DdSI5H8D.js';
|
|
2
|
+
export { M as MapViewWithModal } from './assets/map-view-with-modal-dYGc6zQN.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { c as RouteViewTotems } from './assets/route-view-totems-
|
|
2
|
-
import './assets/utils-
|
|
1
|
+
export { c as RouteViewTotems } from './assets/route-view-totems-DdSI5H8D.js';
|
|
2
|
+
import './assets/utils-Fh1PwBJP.js';
|
|
3
3
|
//# sourceMappingURL=route-view-totems.js.map
|