Dashboard: altitude (gnss.alt, the terrain's while simulating), the car tilted by the terrain's slope while simulating; free look while following (the map moved by hand pauses the follow, "Back to the position" or 15 s resumes it); overlays and shown library files remembered per device (localStorage), back after a reload once the offline checks are in
CI / check (push) Successful in 24s
CI / deploy (push) Successful in 17s

This commit is contained in:
randy committed 2026-12-01 00:15:08 +01:00
1 parent 8c999919b8
commit 12b4ac6725
9 files changed
+199 -19

No files matched your search

+40
View File
@@ -20,7 +20,47 @@ const ARROW = `<svg viewBox="0 0 24 24" width="26" height="26"><path d="M12 2 L2
// heading stays while standing still (speed in m/s, heading in degrees).
// duration (ms): a linear glide over that long — the time until the next
// fix, so a 1 Hz receiver moves the camera smoothly, not in 10 m jumps.
// Moving the map by hand (drag, zoom, rotate, tilt) pauses the follow, as a
// car navigation does — to look around, change the route — the position
// keeps moving; "Back to the position" or FREE_LOOK_MS without touching the
// map resumes it.
const FREE_LOOK_MS = 15000;
const FOLLOWING_MS = 5000; // a follow step this recently: the map is following
const freeLook = new WeakMap(); // map -> { until, button }
function freeLookState(map) {
let state = freeLook.get(map);
if (state) return state;
const button = document.createElement("button");
button.type = "button";
button.className = "follow-resume";
button.textContent = "Back to the position";
button.hidden = true;
map.getContainer().appendChild(button);
state = { until: 0, button, followedAt: 0 };
button.addEventListener("click", () => {
state.until = 0;
button.hidden = true;
clearTimeout(state.timer);
});
const touched = (e) => {
// our own easeTo, or nothing being followed (GNSS off)
if (!e.originalEvent || Date.now() - state.followedAt > FOLLOWING_MS) return;
state.until = Date.now() + FREE_LOOK_MS;
button.hidden = false;
clearTimeout(state.timer);
state.timer = setTimeout(() => (button.hidden = true), FREE_LOOK_MS);
};
for (const type of ["dragstart", "zoomstart", "rotatestart", "pitchstart", "move"]) map.on(type, touched);
freeLook.set(map, state);
return state;
}
export function followPosition(map, lngLat, heading, speed, duration) {
const free = freeLookState(map);
free.followedAt = Date.now();
if (Date.now() < free.until) return;
free.button.hidden = true;
const pitched = map.getPitch() > 0;
const moving = Number.isFinite(heading) && (speed ?? 0) >= 1;
map.easeTo({