@mapvx/web-js 3.5.1-dev.1 → 3.6.0-dev.1
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/cjs/logger/sentry.js +1 -1
- package/dist/cjs/map/fitCamera.js +1 -1
- package/dist/cjs/map/fitCamera.js.map +1 -1
- package/dist/cjs/map/liveMapFitTransform.js +180 -0
- package/dist/cjs/map/liveMapFitTransform.js.map +1 -0
- package/dist/cjs/map/map.js +12 -1
- package/dist/cjs/map/map.js.map +1 -1
- package/dist/es/logger/sentry.js +1 -1
- package/dist/es/map/fitCamera.d.ts +7 -5
- package/dist/es/map/fitCamera.d.ts.map +1 -1
- package/dist/es/map/fitCamera.js +1 -1
- package/dist/es/map/fitCamera.js.map +1 -1
- package/dist/es/map/liveMapFitTransform.d.ts +98 -0
- package/dist/es/map/liveMapFitTransform.d.ts.map +1 -0
- package/dist/es/map/liveMapFitTransform.js +176 -0
- package/dist/es/map/liveMapFitTransform.js.map +1 -0
- package/dist/es/map/map.d.ts.map +1 -1
- package/dist/es/map/map.js +12 -1
- package/dist/es/map/map.js.map +1 -1
- package/dist/umd/index.js +218 -8
- package/dist/umd/index.js.map +1 -1
- package/package.json +1 -4
|
@@ -14,7 +14,7 @@ const browser_1 = require("@sentry/browser");
|
|
|
14
14
|
// exists only for the type-checker, so in the ES/CJS builds the identifier is
|
|
15
15
|
// genuinely absent and a direct comparison throws ReferenceError at module load.
|
|
16
16
|
// `typeof` is the only safe way to probe a possibly-undeclared global.
|
|
17
|
-
const SDK_VERSION = typeof VERSION === "undefined" ? "3.
|
|
17
|
+
const SDK_VERSION = typeof VERSION === "undefined" ? "3.6.0-dev.1" : VERSION;
|
|
18
18
|
const DSN = typeof SENTRY_DSN !== "undefined" && SENTRY_DSN
|
|
19
19
|
? SENTRY_DSN
|
|
20
20
|
: "https://872f598f020e3cd73a0933b562d24c81@sentry.mapvx.app/5";
|
|
@@ -67,7 +67,7 @@ function computeOrientedCamera(coordinates, params) {
|
|
|
67
67
|
* If any point falls behind the horizon during refinement, it bails out and
|
|
68
68
|
* returns the best camera computed so far (never worse than the flat input).
|
|
69
69
|
*
|
|
70
|
-
* @param transform
|
|
70
|
+
* @param transform Camera simulator used purely for projection; the caller owns its lifecycle.
|
|
71
71
|
* @param coordinates Points to fit.
|
|
72
72
|
* @param initial The orthographic camera to refine.
|
|
73
73
|
* @param params Bearing, pitch, padding and viewport constraints.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fitCamera.js","sourceRoot":"","sources":["../../../src/map/fitCamera.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"fitCamera.js","sourceRoot":"","sources":["../../../src/map/fitCamera.ts"],"names":[],"mappings":";;AAoFA,sDAwCC;AAqBD,oDA4DC;AA7MD,6CAA+D;AA8D/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,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ACjC,CAAC;QACD,2EAA2E;QAC3E,4DAA4D;QAC5D,IAAI,CAAC,YAAY;YAAE,MAAK;QAExB,yEAAyE;QACzE,MAAM,SAAS,GAAG,IAAI,mBAAK,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,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"}
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LiveMapFitTransform = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Screen-space tolerance, in pixels, for the horizon round-trip test.
|
|
6
|
+
*
|
|
7
|
+
* `project` and `unproject` are not exact inverses — they run through a 4x4 matrix and its
|
|
8
|
+
* inverse, so a well-behaved point still drifts by a fraction of a pixel. Half a pixel is far
|
|
9
|
+
* below that drift's ceiling and far above the millions-of-pixels divergence a point behind the
|
|
10
|
+
* horizon produces, so the threshold is not sensitive to its exact value.
|
|
11
|
+
*/
|
|
12
|
+
const SURFACE_ROUND_TRIP_EPSILON_PX = 0.5;
|
|
13
|
+
/**
|
|
14
|
+
* A {@link FitTransform} backed by a live MapLibre map and its public API.
|
|
15
|
+
*
|
|
16
|
+
* ## Why this exists
|
|
17
|
+
*
|
|
18
|
+
* {@link refineCameraForPitch} needs to project points through MapLibre's real perspective
|
|
19
|
+
* projection for camera states the map is not actually in — it tries a candidate camera, measures
|
|
20
|
+
* where the geometry lands, adjusts, and repeats. Until MapLibre v6 that was done on
|
|
21
|
+
* `map.transform.clone()`, a detached copy of the internal transform.
|
|
22
|
+
*
|
|
23
|
+
* v6 removed `map.transform` and exposes no replacement: there is no exported `Camera`,
|
|
24
|
+
* `Transform` or `MercatorTransform`, and the migration guide says only "use `Map`'s public API
|
|
25
|
+
* instead". So the simulation moves onto the map itself.
|
|
26
|
+
*
|
|
27
|
+
* ## How it stays invisible
|
|
28
|
+
*
|
|
29
|
+
* The map is genuinely moved, but never painted mid-simulation: MapLibre renders on
|
|
30
|
+
* `requestAnimationFrame`, and every mutation here happens inside one synchronous block that ends
|
|
31
|
+
* with {@link restore}. No intermediate frame exists to be seen.
|
|
32
|
+
*
|
|
33
|
+
* Camera writes are also batched. Setters only record intent; the map is moved at most once per
|
|
34
|
+
* refinement iteration, lazily, the first time a projection actually needs the new camera.
|
|
35
|
+
*
|
|
36
|
+
* ## What it costs
|
|
37
|
+
*
|
|
38
|
+
* `jumpTo` fires camera events, so listeners observe movement that no user caused. At the only
|
|
39
|
+
* call site this is bounded — the refinement is immediately followed by a real `easeTo`, so the
|
|
40
|
+
* map was going to move regardless, and the `moveend` handler that reports completion is attached
|
|
41
|
+
* *after* refinement and so cannot see the simulation's events.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* const transform = new LiveMapFitTransform(map)
|
|
46
|
+
* try {
|
|
47
|
+
* camera = refineCameraForPitch(transform, coordinates, camera, params)
|
|
48
|
+
* } finally {
|
|
49
|
+
* transform.restore()
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* @group Map
|
|
54
|
+
*/
|
|
55
|
+
class LiveMapFitTransform {
|
|
56
|
+
/**
|
|
57
|
+
* Capture the map's current camera so it can be restored, and seed the simulation with it.
|
|
58
|
+
*
|
|
59
|
+
* @param map The live map to simulate on.
|
|
60
|
+
*/
|
|
61
|
+
constructor(map) {
|
|
62
|
+
var _a, _b, _c, _d;
|
|
63
|
+
/** Whether {@link pending} has diverged from what the map is currently showing. */
|
|
64
|
+
this.dirty = false;
|
|
65
|
+
/**
|
|
66
|
+
* Whether the map was ever actually moved.
|
|
67
|
+
*
|
|
68
|
+
* Tracked separately from {@link dirty}, which {@link sync} clears the moment it flushes: keying
|
|
69
|
+
* {@link restore} off `dirty` alone would make it a no-op right after a flush and strand the map
|
|
70
|
+
* on a candidate camera.
|
|
71
|
+
*/
|
|
72
|
+
this.moved = false;
|
|
73
|
+
this.setCenter = (center) => {
|
|
74
|
+
this.pending.center = center;
|
|
75
|
+
this.dirty = true;
|
|
76
|
+
};
|
|
77
|
+
this.setZoom = (zoom) => {
|
|
78
|
+
this.pending.zoom = zoom;
|
|
79
|
+
this.dirty = true;
|
|
80
|
+
};
|
|
81
|
+
this.setBearing = (bearing) => {
|
|
82
|
+
this.pending.bearing = bearing;
|
|
83
|
+
this.dirty = true;
|
|
84
|
+
};
|
|
85
|
+
this.setPitch = (pitch) => {
|
|
86
|
+
this.pending.pitch = pitch;
|
|
87
|
+
this.dirty = true;
|
|
88
|
+
};
|
|
89
|
+
this.setPadding = (padding) => {
|
|
90
|
+
this.pending.padding = padding;
|
|
91
|
+
this.dirty = true;
|
|
92
|
+
};
|
|
93
|
+
this.locationToScreenPoint = (lnglat) => {
|
|
94
|
+
this.sync();
|
|
95
|
+
return this.map.project(lnglat);
|
|
96
|
+
};
|
|
97
|
+
this.screenPointToLocation = (p) => {
|
|
98
|
+
this.sync();
|
|
99
|
+
return this.map.unproject(p);
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Whether a projected point lies on the visible map surface rather than beyond the horizon.
|
|
103
|
+
*
|
|
104
|
+
* MapLibre exposes no public horizon test, so this uses a round-trip: unprojecting a screen
|
|
105
|
+
* point casts a ray onto the map plane, and re-projecting that location lands back where it
|
|
106
|
+
* started only if the ray actually met the plane in front of the camera. Past the horizon the
|
|
107
|
+
* ray diverges and the round-trip misses by an enormous margin.
|
|
108
|
+
*
|
|
109
|
+
* @param p Screen point, as returned by {@link locationToScreenPoint}.
|
|
110
|
+
* @returns `true` when the point is on the map surface.
|
|
111
|
+
*/
|
|
112
|
+
this.isPointOnMapSurface = (p) => {
|
|
113
|
+
this.sync();
|
|
114
|
+
const roundTripped = this.map.project(this.map.unproject(p));
|
|
115
|
+
return (Number.isFinite(roundTripped.x) &&
|
|
116
|
+
Number.isFinite(roundTripped.y) &&
|
|
117
|
+
Math.abs(roundTripped.x - p.x) < SURFACE_ROUND_TRIP_EPSILON_PX &&
|
|
118
|
+
Math.abs(roundTripped.y - p.y) < SURFACE_ROUND_TRIP_EPSILON_PX);
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Put the camera back exactly as it was when this instance was constructed.
|
|
122
|
+
*
|
|
123
|
+
* Safe to call more than once, and safe to call when nothing was ever changed. Always call it
|
|
124
|
+
* from a `finally` block so a throw mid-refinement cannot strand the map on a candidate camera.
|
|
125
|
+
*/
|
|
126
|
+
this.restore = () => {
|
|
127
|
+
if (!this.moved) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
this.map.jumpTo({
|
|
131
|
+
center: this.snapshot.center,
|
|
132
|
+
zoom: this.snapshot.zoom,
|
|
133
|
+
bearing: this.snapshot.bearing,
|
|
134
|
+
pitch: this.snapshot.pitch,
|
|
135
|
+
padding: this.snapshot.padding,
|
|
136
|
+
});
|
|
137
|
+
this.pending = Object.assign({}, this.snapshot);
|
|
138
|
+
this.dirty = false;
|
|
139
|
+
this.moved = false;
|
|
140
|
+
};
|
|
141
|
+
this.map = map;
|
|
142
|
+
const padding = map.getPadding();
|
|
143
|
+
this.snapshot = {
|
|
144
|
+
center: map.getCenter(),
|
|
145
|
+
zoom: map.getZoom(),
|
|
146
|
+
bearing: map.getBearing(),
|
|
147
|
+
pitch: map.getPitch(),
|
|
148
|
+
padding: {
|
|
149
|
+
top: (_a = padding.top) !== null && _a !== void 0 ? _a : 0,
|
|
150
|
+
bottom: (_b = padding.bottom) !== null && _b !== void 0 ? _b : 0,
|
|
151
|
+
left: (_c = padding.left) !== null && _c !== void 0 ? _c : 0,
|
|
152
|
+
right: (_d = padding.right) !== null && _d !== void 0 ? _d : 0,
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
this.pending = Object.assign({}, this.snapshot);
|
|
156
|
+
}
|
|
157
|
+
get center() {
|
|
158
|
+
return this.pending.center;
|
|
159
|
+
}
|
|
160
|
+
get zoom() {
|
|
161
|
+
return this.pending.zoom;
|
|
162
|
+
}
|
|
163
|
+
/** Flush {@link pending} onto the map, but only when a projection actually needs it. */
|
|
164
|
+
sync() {
|
|
165
|
+
if (!this.dirty) {
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
this.map.jumpTo({
|
|
169
|
+
center: this.pending.center,
|
|
170
|
+
zoom: this.pending.zoom,
|
|
171
|
+
bearing: this.pending.bearing,
|
|
172
|
+
pitch: this.pending.pitch,
|
|
173
|
+
padding: this.pending.padding,
|
|
174
|
+
});
|
|
175
|
+
this.dirty = false;
|
|
176
|
+
this.moved = true;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
exports.LiveMapFitTransform = LiveMapFitTransform;
|
|
180
|
+
//# sourceMappingURL=liveMapFitTransform.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"liveMapFitTransform.js","sourceRoot":"","sources":["../../../src/map/liveMapFitTransform.ts"],"names":[],"mappings":";;;AAIA;;;;;;;GAOG;AACH,MAAM,6BAA6B,GAAG,GAAG,CAAA;AAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,MAAa,mBAAmB;IAiC9B;;;;OAIG;IACH,YAAY,GAAgB;;QAjB5B,mFAAmF;QAC3E,UAAK,GAAG,KAAK,CAAA;QAErB;;;;;;WAMG;QACK,UAAK,GAAG,KAAK,CAAA;QAkCrB,cAAS,GAAG,CAAC,MAAc,EAAQ,EAAE;YACnC,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,MAAM,CAAA;YAC5B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACnB,CAAC,CAAA;QAED,YAAO,GAAG,CAAC,IAAY,EAAQ,EAAE;YAC/B,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAA;YACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACnB,CAAC,CAAA;QAED,eAAU,GAAG,CAAC,OAAe,EAAQ,EAAE;YACrC,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAA;YAC9B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACnB,CAAC,CAAA;QAED,aAAQ,GAAG,CAAC,KAAa,EAAQ,EAAE;YACjC,IAAI,CAAC,OAAO,CAAC,KAAK,GAAG,KAAK,CAAA;YAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACnB,CAAC,CAAA;QAED,eAAU,GAAG,CAAC,OAAqB,EAAQ,EAAE;YAC3C,IAAI,CAAC,OAAO,CAAC,OAAO,GAAG,OAAO,CAAA;YAC9B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACnB,CAAC,CAAA;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M;YAC3B,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;YACvB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;YAC7B,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK;YACzB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;SAC9B,CAAC,CAAA;QACF,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;IACnB,CAAC;CACF;AA/JD,kDA+JC"}
|
package/dist/cjs/map/map.js
CHANGED
|
@@ -214,6 +214,7 @@ const route_utils_1 = require("../utils/route-utils");
|
|
|
214
214
|
const utils_1 = require("../utils/utils");
|
|
215
215
|
const scene3DController_1 = require("./scene3DController");
|
|
216
216
|
const fitCamera_1 = require("./fitCamera");
|
|
217
|
+
const liveMapFitTransform_1 = require("./liveMapFitTransform");
|
|
217
218
|
const mapInteractionOptions_1 = require("./mapInteractionOptions");
|
|
218
219
|
/**
|
|
219
220
|
* Class to interact with the map.
|
|
@@ -1930,7 +1931,17 @@ class InternalMapVXMap extends loggeable_1.Loggeable {
|
|
|
1930
1931
|
// With a tilted camera the orthographic zoom is off due to perspective, so
|
|
1931
1932
|
// refine it against maplibre's real projection on a cloned transform.
|
|
1932
1933
|
if (pitch > 0) {
|
|
1933
|
-
|
|
1934
|
+
// Simulated on the live map through its public API rather than on `map.transform.clone()`:
|
|
1935
|
+
// MapLibre v6 removes the internal transform and exposes no replacement. The whole loop is
|
|
1936
|
+
// synchronous and ends in `restore()`, so no intermediate frame is ever painted.
|
|
1937
|
+
// See DEVELOPER_DOCS/MAPLIBRE_V6_MIGRATION.md.
|
|
1938
|
+
const fitTransform = new liveMapFitTransform_1.LiveMapFitTransform(this.map);
|
|
1939
|
+
try {
|
|
1940
|
+
camera = (0, fitCamera_1.refineCameraForPitch)(fitTransform, coordinates, camera, Object.assign(Object.assign({}, cameraParams), { pitch }));
|
|
1941
|
+
}
|
|
1942
|
+
finally {
|
|
1943
|
+
fitTransform.restore();
|
|
1944
|
+
}
|
|
1934
1945
|
}
|
|
1935
1946
|
if (onComplete) {
|
|
1936
1947
|
void this.map.once("moveend", onComplete);
|