@mapvx/web-js 1.4.0-dev.0 → 1.4.0-dev.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/LICENSE.md +2 -2
- package/README.md +10 -9
- package/dist/cjs/assets/icons.js +8 -10
- package/dist/cjs/assets/icons.js.map +1 -1
- package/dist/cjs/controllers/routeController.js +27 -2
- package/dist/cjs/controllers/routeController.js.map +1 -1
- package/dist/cjs/domain/models/_internal.js +1 -2
- package/dist/cjs/domain/models/_internal.js.map +1 -1
- package/dist/cjs/domain/models/animation.js +2 -2
- package/dist/cjs/domain/models/animation.js.map +1 -1
- package/dist/cjs/domain/models/categories.js +3 -4
- package/dist/cjs/domain/models/categories.js.map +1 -1
- package/dist/cjs/domain/models/circle.js +5 -5
- package/dist/cjs/domain/models/circle.js.map +1 -1
- package/dist/cjs/domain/models/mapConfig.js +1 -1
- package/dist/cjs/domain/models/mapConfig.js.map +1 -1
- package/dist/cjs/domain/models/marker.js +80 -86
- package/dist/cjs/domain/models/marker.js.map +1 -1
- package/dist/cjs/domain/models/multilanguage.js +1 -2
- package/dist/cjs/domain/models/multilanguage.js.map +1 -1
- package/dist/cjs/domain/models/place.js.map +1 -1
- package/dist/cjs/domain/models/property.js.map +1 -1
- package/dist/cjs/domain/models/route.js.map +1 -1
- package/dist/cjs/domain/models/routeInstance.js +1 -2
- package/dist/cjs/domain/models/routeInstance.js.map +1 -1
- package/dist/cjs/index.js +12 -12
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/infrastructure/cache/CacheManager.js.map +1 -1
- package/dist/cjs/infrastructure/cache/LRUCache.js.map +1 -1
- package/dist/cjs/infrastructure/cache/PersistentCache.js.map +1 -1
- package/dist/cjs/infrastructure/cache/cacheConfig.js +10 -10
- package/dist/cjs/infrastructure/cache/cacheConfig.js.map +1 -1
- package/dist/cjs/infrastructure/http/FetchHttpClient.js.map +1 -1
- package/dist/cjs/infrastructure/logging/CountlyLogger.js.map +1 -1
- package/dist/cjs/logger/logger.js +1 -1
- package/dist/cjs/logger/logger.js.map +1 -1
- package/dist/cjs/logger/rollbar.js +3 -3
- package/dist/cjs/logger/rollbar.js.map +1 -1
- package/dist/cjs/map/fitCamera.js +124 -0
- package/dist/cjs/map/fitCamera.js.map +1 -0
- package/dist/cjs/map/map.js +177 -31
- package/dist/cjs/map/map.js.map +1 -1
- package/dist/cjs/map/mapInteractionOptions.js +2 -3
- package/dist/cjs/map/mapInteractionOptions.js.map +1 -1
- package/dist/cjs/repository/repository.js.map +1 -1
- package/dist/cjs/repository/requester.js.map +1 -1
- package/dist/cjs/sdk.js +2 -3
- package/dist/cjs/sdk.js.map +1 -1
- package/dist/cjs/utils/3d.js +42 -8
- package/dist/cjs/utils/3d.js.map +1 -1
- package/dist/cjs/utils/error.js +1 -2
- package/dist/cjs/utils/error.js.map +1 -1
- package/dist/cjs/utils/images.js +1 -2
- package/dist/cjs/utils/images.js.map +1 -1
- package/dist/cjs/utils/loadGlb.js +3 -4
- package/dist/cjs/utils/loadGlb.js.map +1 -1
- package/dist/cjs/utils/mapvxHostname.js +1 -2
- package/dist/cjs/utils/mapvxHostname.js.map +1 -1
- package/dist/cjs/utils/nav-functions.js +4 -4
- package/dist/cjs/utils/nav-functions.js.map +1 -1
- package/dist/cjs/utils/opening-hours-helper.js +2 -2
- package/dist/cjs/utils/opening-hours-helper.js.map +1 -1
- package/dist/cjs/utils/preconnect.js +2 -2
- package/dist/cjs/utils/preconnect.js.map +1 -1
- package/dist/cjs/utils/route-utils.js +1 -2
- package/dist/cjs/utils/route-utils.js.map +1 -1
- package/dist/cjs/utils/semaphore.js.map +1 -1
- package/dist/cjs/utils/three.js +17 -7
- package/dist/cjs/utils/three.js.map +1 -1
- package/dist/cjs/utils/update-css.js +2 -3
- package/dist/cjs/utils/update-css.js.map +1 -1
- package/dist/cjs/utils/utils.js +5 -6
- package/dist/cjs/utils/utils.js.map +1 -1
- package/dist/es/assets/icons.d.ts +4 -4
- package/dist/es/assets/icons.d.ts.map +1 -1
- package/dist/es/assets/icons.js +6 -8
- package/dist/es/assets/icons.js.map +1 -1
- package/dist/es/controllers/routeController.d.ts +8 -0
- package/dist/es/controllers/routeController.d.ts.map +1 -1
- package/dist/es/controllers/routeController.js +27 -2
- package/dist/es/controllers/routeController.js.map +1 -1
- package/dist/es/domain/models/animation.d.ts +3 -3
- package/dist/es/domain/models/animation.js +2 -2
- package/dist/es/domain/models/animation.js.map +1 -1
- package/dist/es/domain/models/circle.d.ts.map +1 -1
- package/dist/es/domain/models/circle.js.map +1 -1
- package/dist/es/domain/models/mapConfig.js +1 -1
- package/dist/es/domain/models/mapConfig.js.map +1 -1
- package/dist/es/domain/models/marker.d.ts +0 -8
- package/dist/es/domain/models/marker.d.ts.map +1 -1
- package/dist/es/domain/models/marker.js +80 -86
- package/dist/es/domain/models/marker.js.map +1 -1
- package/dist/es/domain/models/place.js.map +1 -1
- package/dist/es/domain/models/property.js.map +1 -1
- package/dist/es/domain/models/route.js.map +1 -1
- package/dist/es/domain/models/scene3D.d.ts +34 -4
- package/dist/es/domain/models/scene3D.d.ts.map +1 -1
- package/dist/es/index.d.ts +10 -10
- package/dist/es/index.d.ts.map +1 -1
- package/dist/es/index.js +5 -5
- package/dist/es/index.js.map +1 -1
- package/dist/es/infrastructure/cache/CacheManager.js.map +1 -1
- package/dist/es/infrastructure/cache/LRUCache.js.map +1 -1
- package/dist/es/infrastructure/cache/PersistentCache.js.map +1 -1
- package/dist/es/infrastructure/cache/cacheConfig.js +8 -8
- package/dist/es/infrastructure/cache/cacheConfig.js.map +1 -1
- package/dist/es/infrastructure/http/FetchHttpClient.js.map +1 -1
- package/dist/es/infrastructure/logging/CountlyLogger.js.map +1 -1
- package/dist/es/interfaces/routeCacheResponse.d.ts.map +1 -1
- package/dist/es/logger/logger.js +1 -1
- package/dist/es/logger/logger.js.map +1 -1
- package/dist/es/logger/rollbar.js +1 -1
- package/dist/es/map/fitCamera.d.ts +94 -0
- package/dist/es/map/fitCamera.d.ts.map +1 -0
- package/dist/es/map/fitCamera.js +120 -0
- package/dist/es/map/fitCamera.js.map +1 -0
- package/dist/es/map/map.d.ts +65 -6
- package/dist/es/map/map.d.ts.map +1 -1
- package/dist/es/map/map.js +161 -25
- package/dist/es/map/map.js.map +1 -1
- package/dist/es/map/mapInteractionOptions.js.map +1 -1
- package/dist/es/repository/repository.js.map +1 -1
- package/dist/es/repository/requester.js.map +1 -1
- package/dist/es/sdk.d.ts.map +1 -1
- package/dist/es/sdk.js +0 -1
- package/dist/es/sdk.js.map +1 -1
- package/dist/es/utils/3d.d.ts +32 -1
- package/dist/es/utils/3d.d.ts.map +1 -1
- package/dist/es/utils/3d.js +31 -0
- package/dist/es/utils/3d.js.map +1 -1
- package/dist/es/utils/error.js.map +1 -1
- package/dist/es/utils/loadGlb.js.map +1 -1
- package/dist/es/utils/mapvxHostname.js.map +1 -1
- package/dist/es/utils/opening-hours-helper.js.map +1 -1
- package/dist/es/utils/preconnect.js.map +1 -1
- package/dist/es/utils/route-utils.js.map +1 -1
- package/dist/es/utils/semaphore.js.map +1 -1
- package/dist/es/utils/update-css.js +1 -1
- package/dist/es/utils/update-css.js.map +1 -1
- package/dist/es/utils/utils.js.map +1 -1
- package/dist/umd/index.js +51135 -40072
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/styles.css +14 -32
- package/dist/umd/styles.css.map +1 -1
- package/dist/umd/styles.js +3 -3
- package/dist/umd/styles.js.map +1 -1
- package/package.json +36 -24
- package/dist/cjs/assets/route_animation_icon.svg +0 -15
- package/dist/cjs/assets/user-dot-icon.svg +0 -3
- package/dist/es/assets/route_animation_icon.svg +0 -15
- package/dist/es/assets/user-dot-icon.svg +0 -3
|
@@ -15,7 +15,7 @@ const rollbar_2 = require("./rollbar");
|
|
|
15
15
|
// by scripts/inject-build-defines.js. The Countly key falls back to the
|
|
16
16
|
// MapVX key when none is injected at build time.
|
|
17
17
|
const IS_DEBUG = typeof DEBUG !== "undefined" ? DEBUG : false;
|
|
18
|
-
const SDK_VERSION = typeof VERSION !== "undefined" ? VERSION : "1.4.0-dev.
|
|
18
|
+
const SDK_VERSION = typeof VERSION !== "undefined" ? VERSION : "1.4.0-dev.2";
|
|
19
19
|
const COUNTLY_API_KEY = typeof COUNTLY_KEY !== "undefined" && COUNTLY_KEY
|
|
20
20
|
? COUNTLY_KEY
|
|
21
21
|
: "f0c8d3b96d336e857a8628f49dd1baf7d7add0e9";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/logger/logger.ts"],"names":[],"mappings":";;;;;;AAAA,sEAAqC;AACrC,sDAAmD;AACnD,uCAA0C;AAU1C,qEAAqE;AACrE,6EAA6E;AAC7E,qEAAqE;AACrE,oEAAoE;AACpE,2EAA2E;AAC3E,wEAAwE;AACxE,iDAAiD;AACjD,MAAM,QAAQ,GAAY,OAAO,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAA;AACtE,MAAM,WAAW,GAAW,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAA;AACxF,MAAM,eAAe,GACnB,OAAO,WAAW,KAAK,WAAW,IAAI,WAAW;IAC/C,CAAC,CAAC,WAAW;IACb,CAAC,CAAC,0CAA0C,CAAA;AAEhD,MAAM,OAAO,GAAG;IACd,MAAM,EAAE,eAAe;IACvB,GAAG,EAAE,+BAA+B;CACrC,CAAA;AAED,MAAa,MAAM;IAOjB;;QACE,IAAI,QAAQ,EAAE;
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/logger/logger.ts"],"names":[],"mappings":";;;;;;AAAA,sEAAqC;AACrC,sDAAmD;AACnD,uCAA0C;AAU1C,qEAAqE;AACrE,6EAA6E;AAC7E,qEAAqE;AACrE,oEAAoE;AACpE,2EAA2E;AAC3E,wEAAwE;AACxE,iDAAiD;AACjD,MAAM,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
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports._rollbarConfig = void 0;
|
|
4
|
+
exports.argsToDict = argsToDict;
|
|
4
5
|
// VERSION and ROLLBAR_ACCESS_TOKEN are webpack DefinePlugin constants,
|
|
5
6
|
// substituted only in the UMD bundle. The tsc-built ES/CJS outputs keep them
|
|
6
7
|
// as bare globals, so the typeof guards make the lookup safe everywhere; the
|
|
7
8
|
// version placeholder is replaced with the package version by
|
|
8
9
|
// scripts/inject-build-defines.js. The access token falls back to the MapVX
|
|
9
10
|
// SDK-web Rollbar project token when none is injected at build time.
|
|
10
|
-
const SDK_VERSION = typeof VERSION !== "undefined" ? VERSION : "1.4.0-dev.
|
|
11
|
+
const SDK_VERSION = typeof VERSION !== "undefined" ? VERSION : "1.4.0-dev.2";
|
|
11
12
|
const ACCESS_TOKEN = typeof ROLLBAR_ACCESS_TOKEN !== "undefined" && ROLLBAR_ACCESS_TOKEN
|
|
12
13
|
? ROLLBAR_ACCESS_TOKEN
|
|
13
14
|
: "28279d52df43411ebd138c2bee0ab1df";
|
|
@@ -33,5 +34,4 @@ exports._rollbarConfig = {
|
|
|
33
34
|
function argsToDict(...args) {
|
|
34
35
|
return Object.fromEntries(args.map((val, idx) => [idx, val]));
|
|
35
36
|
}
|
|
36
|
-
exports.argsToDict = argsToDict;
|
|
37
37
|
//# sourceMappingURL=rollbar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rollbar.js","sourceRoot":"","sources":["../../../src/logger/rollbar.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"rollbar.js","sourceRoot":"","sources":["../../../src/logger/rollbar.ts"],"names":[],"mappings":";;;AAqCA,gCAEC;AAlCD,uEAAuE;AACvE,6EAA6E;AAC7E,6EAA6E;AAC7E,8DAA8D;AAC9D,4EAA4E;AAC5E,qEAAqE;AACrE,MAAM,WAAW,GAAW,OAAO,OAAO,KAAK,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,iBAAiB,CAAA;AACxF,MAAM,YAAY,GAChB,OAAO,oBAAoB,KAAK,WAAW,IAAI,oBAAoB;IACjE,CAAC,CAAC,oBAAoB;IACtB,CAAC,CAAC,kCAAkC,CAAA;AAE3B,QAAA,cAAc,GAAkB;IAC3C,WAAW,EAAE,YAAY;IACzB,yEAAyE;IACzE,uEAAuE;IACvE,uEAAuE;IACvE,6BAA6B;IAC7B,eAAe,EAAE,KAAK;IACtB,0BAA0B,EAAE,KAAK;IACjC,wDAAwD;IACxD,WAAW,EAAE,OAAO;IACpB,OAAO,EAAE;QACP,WAAW,EAAE,YAAY;QACzB,MAAM,EAAE;YACN,UAAU,EAAE;gBACV,YAAY,EAAE,WAAW;aAC1B;SACF;KACF;CACF,CAAA;AAED,SAAgB,UAAU,CAAC,GAAG,IAAmB;IAC/C,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAAA;AAC/D,CAAC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.computeOrientedCamera = computeOrientedCamera;
|
|
4
|
+
exports.refineCameraForPitch = refineCameraForPitch;
|
|
5
|
+
const maplibre_gl_1 = require("maplibre-gl");
|
|
6
|
+
/** maplibre world size (px) at zoom 0: tileSize (512) * 2^0. */
|
|
7
|
+
const TILE_SIZE = 512;
|
|
8
|
+
const clamp = (value, min, max) => Math.min(Math.max(value, min), max);
|
|
9
|
+
/**
|
|
10
|
+
* Compute the camera (center + zoom) that tightly fits `coordinates` into the
|
|
11
|
+
* padded viewport for a given bearing, using an ORIENTED bounding box.
|
|
12
|
+
*
|
|
13
|
+
* maplibre's `fitBounds` only fits a north-up `LngLatBounds`, which wastes
|
|
14
|
+
* viewport space for diagonal geometries under a bearing. Instead we rotate the
|
|
15
|
+
* mercator-projected points by the bearing, measure their axis-aligned extent in
|
|
16
|
+
* that rotated frame, and derive zoom + center analytically.
|
|
17
|
+
*
|
|
18
|
+
* This calculation is orthographic (assumes `pitch: 0`). For a tilted camera use
|
|
19
|
+
* {@link refineCameraForPitch} to correct for perspective.
|
|
20
|
+
*
|
|
21
|
+
* @param coordinates Points to fit (must contain at least one).
|
|
22
|
+
* @param params Bearing, padding and viewport constraints.
|
|
23
|
+
* @returns The fitting camera center and zoom.
|
|
24
|
+
*/
|
|
25
|
+
function computeOrientedCamera(coordinates, params) {
|
|
26
|
+
const { bearing, padding, containerWidth, containerHeight, maxZoom, minZoom } = params;
|
|
27
|
+
// Rotate the mercator plane by -bearing so the target bearing becomes axis-aligned.
|
|
28
|
+
const rad = (-bearing * Math.PI) / 180;
|
|
29
|
+
const cos = Math.cos(rad);
|
|
30
|
+
const sin = Math.sin(rad);
|
|
31
|
+
let minX = Infinity;
|
|
32
|
+
let minY = Infinity;
|
|
33
|
+
let maxX = -Infinity;
|
|
34
|
+
let maxY = -Infinity;
|
|
35
|
+
for (const coord of coordinates) {
|
|
36
|
+
const m = maplibre_gl_1.MercatorCoordinate.fromLngLat({ lat: coord.lat, lng: coord.lng });
|
|
37
|
+
const rx = m.x * cos - m.y * sin;
|
|
38
|
+
const ry = m.x * sin + m.y * cos;
|
|
39
|
+
minX = Math.min(minX, rx);
|
|
40
|
+
minY = Math.min(minY, ry);
|
|
41
|
+
maxX = Math.max(maxX, rx);
|
|
42
|
+
maxY = Math.max(maxY, ry);
|
|
43
|
+
}
|
|
44
|
+
const boxW = maxX - minX || Number.EPSILON;
|
|
45
|
+
const boxH = maxY - minY || Number.EPSILON;
|
|
46
|
+
const availW = Math.max(1, containerWidth - padding.left - padding.right);
|
|
47
|
+
const availH = Math.max(1, containerHeight - padding.top - padding.bottom);
|
|
48
|
+
// worldSize (px) = TILE_SIZE * 2^zoom
|
|
49
|
+
const worldSize = Math.min(availW / boxW, availH / boxH);
|
|
50
|
+
const zoom = clamp(Math.log2(worldSize / TILE_SIZE), minZoom, maxZoom);
|
|
51
|
+
// Center of the oriented box, rotated back to geographic space.
|
|
52
|
+
const cxr = (minX + maxX) / 2;
|
|
53
|
+
const cyr = (minY + maxY) / 2;
|
|
54
|
+
const center = new maplibre_gl_1.MercatorCoordinate(cxr * cos + cyr * sin, -cxr * sin + cyr * cos, 0).toLngLat();
|
|
55
|
+
return { center, zoom };
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Refine a fit camera for a non-zero pitch.
|
|
59
|
+
*
|
|
60
|
+
* With `pitch > 0` the ground-to-screen mapping is non-linear (perspective), so
|
|
61
|
+
* the orthographic result from {@link computeOrientedCamera} either overshoots
|
|
62
|
+
* (geometry spills past the padding) or leaves extra space. This iteratively
|
|
63
|
+
* projects every point through maplibre's real perspective projection on a cloned
|
|
64
|
+
* transform (no visible camera movement) and adjusts zoom + center until the
|
|
65
|
+
* projected bounding box fits the padded viewport.
|
|
66
|
+
*
|
|
67
|
+
* If any point falls behind the horizon during refinement, it bails out and
|
|
68
|
+
* returns the best camera computed so far (never worse than the flat input).
|
|
69
|
+
*
|
|
70
|
+
* @param transform A `map.transform.clone()` used purely for projection.
|
|
71
|
+
* @param coordinates Points to fit.
|
|
72
|
+
* @param initial The orthographic camera to refine.
|
|
73
|
+
* @param params Bearing, pitch, padding and viewport constraints.
|
|
74
|
+
* @returns The refined camera center and zoom.
|
|
75
|
+
*/
|
|
76
|
+
function refineCameraForPitch(transform, coordinates, initial, params) {
|
|
77
|
+
const { bearing, pitch, padding, containerWidth, containerHeight, maxZoom, minZoom } = params;
|
|
78
|
+
transform.setBearing(bearing);
|
|
79
|
+
transform.setPitch(pitch);
|
|
80
|
+
transform.setPadding(padding);
|
|
81
|
+
transform.setCenter(initial.center);
|
|
82
|
+
transform.setZoom(initial.zoom);
|
|
83
|
+
const availW = Math.max(1, containerWidth - padding.left - padding.right);
|
|
84
|
+
const availH = Math.max(1, containerHeight - padding.top - padding.bottom);
|
|
85
|
+
const MAX_ITERATIONS = 4;
|
|
86
|
+
const CONVERGENCE_EPSILON = 0.01;
|
|
87
|
+
let best = { center: initial.center, zoom: initial.zoom };
|
|
88
|
+
for (let i = 0; i < MAX_ITERATIONS; i++) {
|
|
89
|
+
let minX = Infinity;
|
|
90
|
+
let minY = Infinity;
|
|
91
|
+
let maxX = -Infinity;
|
|
92
|
+
let maxY = -Infinity;
|
|
93
|
+
let allOnSurface = true;
|
|
94
|
+
for (const coord of coordinates) {
|
|
95
|
+
const screen = transform.locationToScreenPoint(new maplibre_gl_1.LngLat(coord.lng, coord.lat));
|
|
96
|
+
if (!transform.isPointOnMapSurface(screen)) {
|
|
97
|
+
allOnSurface = false;
|
|
98
|
+
break;
|
|
99
|
+
}
|
|
100
|
+
minX = Math.min(minX, screen.x);
|
|
101
|
+
minY = Math.min(minY, screen.y);
|
|
102
|
+
maxX = Math.max(maxX, screen.x);
|
|
103
|
+
maxY = Math.max(maxY, screen.y);
|
|
104
|
+
}
|
|
105
|
+
// A point behind the horizon makes the projected box meaningless; keep the
|
|
106
|
+
// last valid camera rather than risk an over-zoomed result.
|
|
107
|
+
if (!allOnSurface)
|
|
108
|
+
break;
|
|
109
|
+
// Recenter: move the projected box center onto the padded screen center.
|
|
110
|
+
const boxCenter = new maplibre_gl_1.Point((minX + maxX) / 2, (minY + maxY) / 2);
|
|
111
|
+
transform.setCenter(transform.screenPointToLocation(boxCenter));
|
|
112
|
+
// Rescale zoom so the projected box fills the padded viewport.
|
|
113
|
+
const boxW = Math.max(maxX - minX, 1e-6);
|
|
114
|
+
const boxH = Math.max(maxY - minY, 1e-6);
|
|
115
|
+
const scale = Math.min(availW / boxW, availH / boxH);
|
|
116
|
+
const zoomDelta = Math.log2(scale);
|
|
117
|
+
transform.setZoom(clamp(transform.zoom + zoomDelta, minZoom, maxZoom));
|
|
118
|
+
best = { center: transform.center, zoom: transform.zoom };
|
|
119
|
+
if (Math.abs(zoomDelta) < CONVERGENCE_EPSILON)
|
|
120
|
+
break;
|
|
121
|
+
}
|
|
122
|
+
return best;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=fitCamera.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fitCamera.js","sourceRoot":"","sources":["../../../src/map/fitCamera.ts"],"names":[],"mappings":";;AAkFA,sDAwCC;AAqBD,oDA4DC;AA3MD,6CAA+D;AA4D/D,gEAAgE;AAChE,MAAM,SAAS,GAAG,GAAG,CAAA;AAErB,MAAM,KAAK,GAAG,CAAC,KAAa,EAAE,GAAW,EAAE,GAAW,EAAU,EAAE,CAChE,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,EAAE,GAAG,CAAC,CAAA;AAErC;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,qBAAqB,CACnC,WAAqB,EACrB,MAA4B;IAE5B,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,MAAM,CAAA;IAEtF,oFAAoF;IACpF,MAAM,GAAG,GAAG,CAAC,CAAC,OAAO,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,GAAG,CAAA;IACtC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IACzB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAEzB,IAAI,IAAI,GAAG,QAAQ,CAAA;IACnB,IAAI,IAAI,GAAG,QAAQ,CAAA;IACnB,IAAI,IAAI,GAAG,CAAC,QAAQ,CAAA;IACpB,IAAI,IAAI,GAAG,CAAC,QAAQ,CAAA;IACpB,KAAK,MAAM,KAAK,IAAI,WAAW,EAAE,CAAC;QAChC,MAAM,CAAC,GAAG,g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AC,EAAE,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;QACjE,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,qBAAqB,CAAC,SAAS,CAAC,CAAC,CAAA;QAE/D,+DAA+D;QAC/D,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,EAAE,IAAI,CAAC,CAAA;QACxC,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,EAAE,IAAI,CAAC,CAAA;QACxC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,GAAG,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC,CAAA;QACpD,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;QAClC,SAAS,CAAC,OAAO,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;QAEtE,IAAI,GAAG,EAAE,MAAM,EAAE,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,CAAA;QAEzD,IAAI,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,mBAAmB;YAAE,MAAK;IACtD,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
|
package/dist/cjs/map/map.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
exports.InternalMapVXMap = void 0;
|
|
27
37
|
const geo_layers_1 = require("@deck.gl/geo-layers");
|
|
@@ -161,9 +171,9 @@ const icons_1 = require("../assets/icons");
|
|
|
161
171
|
const routeController_1 = require("../controllers/routeController");
|
|
162
172
|
const _rtl_1 = require("../domain/models/_rtl");
|
|
163
173
|
const animation_1 = require("../domain/models/animation");
|
|
174
|
+
const circle_1 = require("../domain/models/circle");
|
|
164
175
|
const loggeable_1 = require("../domain/models/loggeable");
|
|
165
176
|
const mapConfig_1 = require("../domain/models/mapConfig");
|
|
166
|
-
const circle_1 = require("../domain/models/circle");
|
|
167
177
|
const marker_1 = require("../domain/models/marker");
|
|
168
178
|
const route_1 = require("../domain/models/route");
|
|
169
179
|
const routeConfiguration_1 = require("../domain/models/routeConfiguration");
|
|
@@ -172,6 +182,7 @@ const _3d_1 = require("../utils/3d");
|
|
|
172
182
|
const loadGlb_1 = require("../utils/loadGlb");
|
|
173
183
|
const route_utils_1 = require("../utils/route-utils");
|
|
174
184
|
const utils_1 = require("../utils/utils");
|
|
185
|
+
const fitCamera_1 = require("./fitCamera");
|
|
175
186
|
const mapInteractionOptions_1 = require("./mapInteractionOptions");
|
|
176
187
|
/**
|
|
177
188
|
* Class to interact with the map.
|
|
@@ -214,6 +225,13 @@ class InternalMapVXMap extends loggeable_1.Loggeable {
|
|
|
214
225
|
this.scene3DGlbLightCount = 0;
|
|
215
226
|
/** Container group holding all placed GLB pivots; rebuilt on each floor change. */
|
|
216
227
|
this.scene3DModelsGroup = undefined;
|
|
228
|
+
/**
|
|
229
|
+
* Route points currently used for GLB route-transparency collision, tagged with the floor on
|
|
230
|
+
* which each point's route segment is visible. Stored as coordinates (not pivot references) so
|
|
231
|
+
* they survive `placeScene3DModels` rebuilds on floor change. Only points matching the current
|
|
232
|
+
* floor participate, so a model only fades when a route is visibly crossing it on that floor.
|
|
233
|
+
*/
|
|
234
|
+
this.scene3DRouteCollisionPoints = [];
|
|
217
235
|
this.spriteIconMapping = {};
|
|
218
236
|
this.spriteAtlasImage = new Image();
|
|
219
237
|
if (_rtl_1.rtlLanguages.includes((_a = mapConfig.lang) !== null && _a !== void 0 ? _a : "")) {
|
|
@@ -371,7 +389,7 @@ class InternalMapVXMap extends loggeable_1.Loggeable {
|
|
|
371
389
|
// Hide MapLibre icon layers — replaced by deck.gl IconLayer
|
|
372
390
|
this.hideLayers((_a = this.scene3DConfig) === null || _a === void 0 ? void 0 : _a.hideLayers);
|
|
373
391
|
const models = (_b = this.scene3DConfig) === null || _b === void 0 ? void 0 : _b.models;
|
|
374
|
-
const glbModelsActive = models !== undefined && models.
|
|
392
|
+
const glbModelsActive = models !== undefined && models.assets.length > 0;
|
|
375
393
|
if (glbModelsActive) {
|
|
376
394
|
this.map.addLayer(this.createGlbCustomLayer());
|
|
377
395
|
}
|
|
@@ -391,7 +409,7 @@ class InternalMapVXMap extends loggeable_1.Loggeable {
|
|
|
391
409
|
});
|
|
392
410
|
this.map.on("zoom", () => {
|
|
393
411
|
if (this.is3DSceneActive()) {
|
|
394
|
-
this.
|
|
412
|
+
this.applyModelOpacity();
|
|
395
413
|
}
|
|
396
414
|
});
|
|
397
415
|
this.map.on("zoomend", () => {
|
|
@@ -551,7 +569,7 @@ class InternalMapVXMap extends loggeable_1.Loggeable {
|
|
|
551
569
|
.multiply(new three_1.THREE.Matrix4().makeRotationX(Math.PI / 2));
|
|
552
570
|
this.scene3DGlbScene = new three_1.THREE.Scene();
|
|
553
571
|
const models = (_a = this.scene3DConfig) === null || _a === void 0 ? void 0 : _a.models;
|
|
554
|
-
if (models && models.
|
|
572
|
+
if (models && models.assets.length > 0) {
|
|
555
573
|
const lights = (0, _3d_1.resolveModels3DLights)(models);
|
|
556
574
|
this.scene3DGlbLightCount = (0, loadGlb_1.addScene3DLights)(this.scene3DGlbScene, lights);
|
|
557
575
|
}
|
|
@@ -614,7 +632,7 @@ class InternalMapVXMap extends loggeable_1.Loggeable {
|
|
|
614
632
|
async loadScene3DGlbTemplates() {
|
|
615
633
|
var _a;
|
|
616
634
|
const models = (_a = this.scene3DConfig) === null || _a === void 0 ? void 0 : _a.models;
|
|
617
|
-
if (!models || models.
|
|
635
|
+
if (!models || models.assets.length === 0) {
|
|
618
636
|
return;
|
|
619
637
|
}
|
|
620
638
|
this.scene3DGlbRootByUrl.clear();
|
|
@@ -635,12 +653,12 @@ class InternalMapVXMap extends loggeable_1.Loggeable {
|
|
|
635
653
|
}
|
|
636
654
|
}
|
|
637
655
|
placeScene3DModels() {
|
|
638
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v
|
|
656
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
639
657
|
if (!this.scene3DGlbScene) {
|
|
640
658
|
return;
|
|
641
659
|
}
|
|
642
660
|
const models = (_a = this.scene3DConfig) === null || _a === void 0 ? void 0 : _a.models;
|
|
643
|
-
if (!models
|
|
661
|
+
if (!models) {
|
|
644
662
|
return;
|
|
645
663
|
}
|
|
646
664
|
if (this.scene3DModelsGroup) {
|
|
@@ -682,15 +700,18 @@ class InternalMapVXMap extends loggeable_1.Loggeable {
|
|
|
682
700
|
this.logWarning(new Error(`Invalid scene3D placement position (assetId=${placement.assetId}, floorKey=${floorKey})`));
|
|
683
701
|
continue;
|
|
684
702
|
}
|
|
685
|
-
const target = maplibre_gl_1.default.MercatorCoordinate.fromLngLat([
|
|
703
|
+
const target = maplibre_gl_1.default.MercatorCoordinate.fromLngLat([
|
|
704
|
+
placement.position.lng,
|
|
705
|
+
placement.position.lat,
|
|
706
|
+
]);
|
|
686
707
|
const sx = (target.x - refMercator.x) / meterScale;
|
|
687
708
|
const sz = (target.y - refMercator.y) / meterScale;
|
|
688
|
-
const ax = (
|
|
689
|
-
const ay = (
|
|
690
|
-
const az = (
|
|
691
|
-
const px = (
|
|
692
|
-
const py = (
|
|
693
|
-
const pz = (
|
|
709
|
+
const ax = (_k = (_j = asset.defaultModelOffset) === null || _j === void 0 ? void 0 : _j.x) !== null && _k !== void 0 ? _k : 0;
|
|
710
|
+
const ay = (_m = (_l = asset.defaultModelOffset) === null || _l === void 0 ? void 0 : _l.y) !== null && _m !== void 0 ? _m : 0;
|
|
711
|
+
const az = (_p = (_o = asset.defaultModelOffset) === null || _o === void 0 ? void 0 : _o.z) !== null && _p !== void 0 ? _p : 0;
|
|
712
|
+
const px = (_r = (_q = placement.offset) === null || _q === void 0 ? void 0 : _q.x) !== null && _r !== void 0 ? _r : 0;
|
|
713
|
+
const py = (_t = (_s = placement.offset) === null || _s === void 0 ? void 0 : _s.y) !== null && _t !== void 0 ? _t : 0;
|
|
714
|
+
const pz = (_v = (_u = placement.offset) === null || _u === void 0 ? void 0 : _u.z) !== null && _v !== void 0 ? _v : 0;
|
|
694
715
|
const pivot = new three_1.THREE.Group();
|
|
695
716
|
pivot.position.set(sx + ax + px, ay + py, sz + az + pz);
|
|
696
717
|
const mergedRot = (0, _3d_1.mergeRotation3D)(asset.defaultRotation, placement.rotation);
|
|
@@ -712,29 +733,109 @@ class InternalMapVXMap extends loggeable_1.Loggeable {
|
|
|
712
733
|
model.position.set(-template.center.x, -template.center.y, -template.center.z);
|
|
713
734
|
// Stash the resolved zoom-transparency config so it can be re-applied on every zoom change.
|
|
714
735
|
pivot.userData.zoomTransparency = (0, _3d_1.resolveZoomTransparency)(models, asset, placement);
|
|
736
|
+
// Stash route-transparency config (may be undefined => feature off for this model) so a
|
|
737
|
+
// route crossing this model can fade it independently of zoom.
|
|
738
|
+
pivot.userData.routeTransparency = (0, _3d_1.resolveRouteTransparency)(models, asset, placement);
|
|
739
|
+
// Precompute the model footprint in the pivot's local x/z frame while `model` has no parent
|
|
740
|
+
// (its world matrix equals its local matrix), for cheap point-in-building collision tests.
|
|
741
|
+
// After `pivot.add(model)` the world matrix would fold in the pivot transform, giving a loose
|
|
742
|
+
// world-axis box instead; `pivot.worldToLocal` at test time undoes the pivot transform.
|
|
743
|
+
const localBox = new three_1.THREE.Box3().setFromObject(model);
|
|
744
|
+
pivot.userData.footprint = {
|
|
745
|
+
minX: localBox.min.x,
|
|
746
|
+
maxX: localBox.max.x,
|
|
747
|
+
minZ: localBox.min.z,
|
|
748
|
+
maxZ: localBox.max.z,
|
|
749
|
+
};
|
|
715
750
|
pivot.add(model);
|
|
716
751
|
modelsGroup.add(pivot);
|
|
717
752
|
}
|
|
718
753
|
this.scene3DModelsGroup = modelsGroup;
|
|
719
754
|
this.scene3DGlbScene.add(modelsGroup);
|
|
720
|
-
|
|
755
|
+
// Recompute route collision against the freshly rebuilt pivots (footprints/floor changed),
|
|
756
|
+
// then apply the combined opacity.
|
|
757
|
+
this.recomputeRouteAffectedModels();
|
|
758
|
+
this.applyModelOpacity();
|
|
721
759
|
this.map.triggerRepaint();
|
|
722
760
|
}
|
|
723
761
|
/**
|
|
724
|
-
*
|
|
725
|
-
*
|
|
726
|
-
*
|
|
727
|
-
*
|
|
762
|
+
* Sets the route path used for GLB route-transparency collision and re-evaluates which models a
|
|
763
|
+
* route currently crosses. Points are tagged with the floor on which their route segment is
|
|
764
|
+
* visible; only points on the current floor participate, so a model never fades unless a route is
|
|
765
|
+
* visibly crossing it on the displayed floor. Pass an empty array to clear.
|
|
766
|
+
*
|
|
767
|
+
* No-op unless the 3D scene is active.
|
|
768
|
+
*/
|
|
769
|
+
setRouteCollisionPath(points) {
|
|
770
|
+
if (!this.is3DSceneActive()) {
|
|
771
|
+
return;
|
|
772
|
+
}
|
|
773
|
+
this.scene3DRouteCollisionPoints = points;
|
|
774
|
+
this.recomputeRouteAffectedModels();
|
|
775
|
+
this.applyModelOpacity();
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Recomputes `pivot.userData.routeAffected` for every placed model by testing the current-floor
|
|
779
|
+
* route collision points against each model's precomputed footprint. Cheap point-in-box tests in
|
|
780
|
+
* the pivot's local x/z frame; runs only when the route path or the placed models change, never
|
|
781
|
+
* per zoom frame.
|
|
782
|
+
*/
|
|
783
|
+
recomputeRouteAffectedModels() {
|
|
784
|
+
var _a;
|
|
785
|
+
if (!this.scene3DModelsGroup) {
|
|
786
|
+
return;
|
|
787
|
+
}
|
|
788
|
+
const floorKey = (_a = this.currentFloor) !== null && _a !== void 0 ? _a : "";
|
|
789
|
+
const points = this.scene3DRouteCollisionPoints.filter((p) => p.floorKey === floorKey);
|
|
790
|
+
// Convert each route point into the models group's local frame (metres relative to
|
|
791
|
+
// initialCenter), exactly as placements are positioned in `placeScene3DModels`. The group's
|
|
792
|
+
// own transform (globalOffset) is applied via `localToWorld` at test time, so route points and
|
|
793
|
+
// model pivots share one frame regardless of the collective offset.
|
|
794
|
+
const refMercator = maplibre_gl_1.MercatorCoordinate.fromLngLat(this.initialCenter, 0);
|
|
795
|
+
const meterScale = refMercator.meterInMercatorCoordinateUnits();
|
|
796
|
+
const groupLocalPoints = points.map((p) => {
|
|
797
|
+
const target = maplibre_gl_1.MercatorCoordinate.fromLngLat([p.lng, p.lat], 0);
|
|
798
|
+
const x = (target.x - refMercator.x) / meterScale;
|
|
799
|
+
const z = (target.y - refMercator.y) / meterScale;
|
|
800
|
+
return new three_1.THREE.Vector3(x, 0, z);
|
|
801
|
+
});
|
|
802
|
+
this.scene3DModelsGroup.updateMatrixWorld(true);
|
|
803
|
+
const local = new three_1.THREE.Vector3();
|
|
804
|
+
for (const pivot of this.scene3DModelsGroup.children) {
|
|
805
|
+
const routeCfg = pivot.userData.routeTransparency;
|
|
806
|
+
const footprint = pivot.userData.footprint;
|
|
807
|
+
// Only models with a route-transparency config participate (feature activation gate).
|
|
808
|
+
if (!routeCfg || !footprint || groupLocalPoints.length === 0) {
|
|
809
|
+
pivot.userData.routeAffected = false;
|
|
810
|
+
continue;
|
|
811
|
+
}
|
|
812
|
+
pivot.userData.routeAffected = groupLocalPoints.some((gp) => {
|
|
813
|
+
// group-local -> world (applies globalOffset) -> pivot-local (undoes position/rotation/
|
|
814
|
+
// scale), then test its x/z against the footprint. y is ignored (floor-level footprint).
|
|
815
|
+
local.copy(gp);
|
|
816
|
+
this.scene3DModelsGroup.localToWorld(local);
|
|
817
|
+
pivot.worldToLocal(local);
|
|
818
|
+
return (0, _3d_1.pointInFootprint)(footprint, local.x, local.z);
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
/**
|
|
823
|
+
* Applies transparency to placed GLB models, combining zoom-based transparency
|
|
824
|
+
* ({@link ZoomTransparencyConfig}) with route-based transparency ({@link RouteTransparencyConfig})
|
|
825
|
+
* for models a route currently crosses (`pivot.userData.routeAffected`). The more transparent of
|
|
826
|
+
* the two wins. Only triggers a repaint when at least one material actually changed.
|
|
728
827
|
*/
|
|
729
|
-
|
|
828
|
+
applyModelOpacity() {
|
|
730
829
|
if (!this.scene3DModelsGroup) {
|
|
731
830
|
return;
|
|
732
831
|
}
|
|
733
832
|
const zoom = this.getZoomLevel();
|
|
734
833
|
let changed = false;
|
|
735
834
|
for (const pivot of this.scene3DModelsGroup.children) {
|
|
736
|
-
const
|
|
737
|
-
const
|
|
835
|
+
const zoomCfg = pivot.userData.zoomTransparency;
|
|
836
|
+
const routeCfg = pivot.userData.routeTransparency;
|
|
837
|
+
const routeAffected = pivot.userData.routeAffected === true;
|
|
838
|
+
const opacity = (0, _3d_1.effectiveModelOpacity)(zoomCfg, routeCfg, zoom, routeAffected);
|
|
738
839
|
pivot.traverse((obj) => {
|
|
739
840
|
const mesh = obj;
|
|
740
841
|
if (!mesh.isMesh) {
|
|
@@ -1771,6 +1872,52 @@ class InternalMapVXMap extends loggeable_1.Loggeable {
|
|
|
1771
1872
|
this.map.fitBounds(bounds, fitOptions);
|
|
1772
1873
|
}
|
|
1773
1874
|
}
|
|
1875
|
+
easeToCoordinates(coordinates, options) {
|
|
1876
|
+
var _a;
|
|
1877
|
+
if (coordinates.length === 0) {
|
|
1878
|
+
return;
|
|
1879
|
+
}
|
|
1880
|
+
const onComplete = options === null || options === void 0 ? void 0 : options.onComplete;
|
|
1881
|
+
// Get container dimensions for percentage-based padding calculations
|
|
1882
|
+
const container = this.map.getContainer();
|
|
1883
|
+
const containerWidth = container.clientWidth;
|
|
1884
|
+
const containerHeight = container.clientHeight;
|
|
1885
|
+
// Convert padding values with units to pixels
|
|
1886
|
+
const padding = convertPaddingToPixels(options === null || options === void 0 ? void 0 : options.padding, containerWidth, containerHeight);
|
|
1887
|
+
if (coordinates.length === 1) {
|
|
1888
|
+
const [coord] = coordinates;
|
|
1889
|
+
if (onComplete) {
|
|
1890
|
+
void this.map.once("moveend", onComplete);
|
|
1891
|
+
}
|
|
1892
|
+
this.map.easeTo(Object.assign(Object.assign({}, options), { center: { lat: coord.lat, lng: coord.lng }, padding }));
|
|
1893
|
+
return;
|
|
1894
|
+
}
|
|
1895
|
+
const bearing = (options === null || options === void 0 ? void 0 : options.bearing) !== undefined ? options.bearing : this.map.getBearing();
|
|
1896
|
+
const pitch = (options === null || options === void 0 ? void 0 : options.pitch) !== undefined ? options.pitch : this.map.getPitch();
|
|
1897
|
+
const cameraParams = {
|
|
1898
|
+
bearing,
|
|
1899
|
+
padding,
|
|
1900
|
+
containerWidth,
|
|
1901
|
+
containerHeight,
|
|
1902
|
+
maxZoom: (_a = options === null || options === void 0 ? void 0 : options.maxZoom) !== null && _a !== void 0 ? _a : this.map.getMaxZoom(),
|
|
1903
|
+
minZoom: this.map.getMinZoom(),
|
|
1904
|
+
};
|
|
1905
|
+
// Orthographic oriented fit (exact for pitch 0). maplibre's fitBounds only
|
|
1906
|
+
// fits a north-up LngLatBounds, which wastes viewport space for diagonal
|
|
1907
|
+
// geometries under a bearing.
|
|
1908
|
+
let camera = (0, fitCamera_1.computeOrientedCamera)(coordinates, cameraParams);
|
|
1909
|
+
// With a tilted camera the orthographic zoom is off due to perspective, so
|
|
1910
|
+
// refine it against maplibre's real projection on a cloned transform.
|
|
1911
|
+
if (pitch > 0) {
|
|
1912
|
+
camera = (0, fitCamera_1.refineCameraForPitch)(this.map.transform.clone(), coordinates, camera, Object.assign(Object.assign({}, cameraParams), { pitch }));
|
|
1913
|
+
}
|
|
1914
|
+
if (onComplete) {
|
|
1915
|
+
void this.map.once("moveend", onComplete);
|
|
1916
|
+
}
|
|
1917
|
+
this.map.easeTo(Object.assign(Object.assign({}, options), { center: camera.center, zoom: camera.zoom, bearing,
|
|
1918
|
+
pitch,
|
|
1919
|
+
padding }));
|
|
1920
|
+
}
|
|
1774
1921
|
fitRouteByPlace(route, placeId, options) {
|
|
1775
1922
|
// Filter steps that belong to the specified place
|
|
1776
1923
|
const stepsInPlace = route.steps.filter((step) => step.startInsidePlace === placeId || step.endInsidePlace === placeId);
|
|
@@ -1824,7 +1971,7 @@ class InternalMapVXMap extends loggeable_1.Loggeable {
|
|
|
1824
1971
|
throw new Error("Error: Failed to add route");
|
|
1825
1972
|
}
|
|
1826
1973
|
}
|
|
1827
|
-
updateRouteProgress(routeId, position, behindStyle = { type: "Solid", color: "#
|
|
1974
|
+
updateRouteProgress(routeId, position, behindStyle = { type: "Solid", color: "#276EF1" }) {
|
|
1828
1975
|
try {
|
|
1829
1976
|
const behindConfig = new routeConfiguration_1.InternalDrawRouteConfiguration({
|
|
1830
1977
|
routeStyle: behindStyle,
|
|
@@ -1880,7 +2027,6 @@ class InternalMapVXMap extends loggeable_1.Loggeable {
|
|
|
1880
2027
|
}
|
|
1881
2028
|
return "";
|
|
1882
2029
|
}
|
|
1883
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1884
2030
|
removePopOver(id) {
|
|
1885
2031
|
throw Error("Not implemented");
|
|
1886
2032
|
}
|