Driving mode ("Drive": big buttons — follow, zoom, 2D/3D, night, route overview — the sidebar hidden); palettes instead of the inversion (the UI's greys onto --ui-*, MapLibre's controls too, night → Night, new ◑ Dusk); the navigated route magenta, the driven part dimmed; route progress only forward (locate near the last position first); rerouting on the server off its own GNSS (TripStore#follow), the browser's only without the shared trip; the overview map hidden while following in 3D; the topbar's items apart
This commit is contained in:
1 parent
12b4ac6725
commit
07a4d363ec
13 files changed
+520
-219
No files matched your search
+23
-10
@@ -38,27 +38,40 @@ function freeLookState(map) {
|
||||
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);
|
||||
});
|
||||
button.addEventListener("click", () => resumeFollow(map));
|
||||
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);
|
||||
if (e.originalEvent && Date.now() - state.followedAt <= FOLLOWING_MS) pauseFollow(map);
|
||||
};
|
||||
for (const type of ["dragstart", "zoomstart", "rotatestart", "pitchstart", "move"]) map.on(type, touched);
|
||||
freeLook.set(map, state);
|
||||
return state;
|
||||
}
|
||||
|
||||
// Also for a view the app moves to itself (the driving bar's route overview).
|
||||
export function pauseFollow(map) {
|
||||
const state = freeLookState(map);
|
||||
state.until = Date.now() + FREE_LOOK_MS;
|
||||
state.button.hidden = false;
|
||||
clearTimeout(state.timer);
|
||||
state.timer = setTimeout(() => (state.button.hidden = true), FREE_LOOK_MS);
|
||||
}
|
||||
|
||||
export function resumeFollow(map) {
|
||||
const state = freeLookState(map);
|
||||
state.until = 0;
|
||||
state.button.hidden = true;
|
||||
clearTimeout(state.timer);
|
||||
}
|
||||
|
||||
export function followPosition(map, lngLat, heading, speed, duration) {
|
||||
const free = freeLookState(map);
|
||||
free.followedAt = Date.now();
|
||||
// following in 3D like a navigation: the overview map out of the way
|
||||
// (style.css), back once the follow stops or the view goes 2D
|
||||
document.documentElement.classList.toggle("follow-3d", map.getPitch() > 0);
|
||||
clearTimeout(free.followTimer);
|
||||
free.followTimer = setTimeout(() => document.documentElement.classList.remove("follow-3d"), FOLLOWING_MS);
|
||||
if (Date.now() < free.until) return;
|
||||
free.button.hidden = true;
|
||||
const pitched = map.getPitch() > 0;
|
||||
|
||||
Reference in new issue
Block a user