Follow zoom closer in town (z18 up to 20 km/h, 15.5 at 120+, the first step z17); TODO: driver's and co-driver's views by whether Android Auto is connected
CI / check (push) Successful in 22s
CI / deploy (push) Successful in 18s

This commit is contained in:
randy committed 2026-12-03 01:29:12 +01:00
1 parent f161243c61
commit 258d35a7a1
2 files changed
+8 -3

No files matched your search

+3 -3
View File
@@ -74,7 +74,7 @@ export function resumeFollow(map) {
// The first step of a follow (or a jump after a gap): zoom in to see the
// road ahead. easeTo, not flyTo — flyTo's swoop zooms out over the distance
// first, the wrong way when starting to drive.
export const FOLLOW_ZOOM = 16;
export const FOLLOW_ZOOM = 17;
export function startFollow(map, lngLat) {
map.easeTo({ center: lngLat, zoom: Math.max(map.getZoom(), FOLLOW_ZOOM), duration: 1000 });
}
@@ -102,11 +102,11 @@ export function followPosition(map, lngLat, heading, speed, duration) {
}
// Auto-zoom like a car navigation: close in town, farther out the faster
// (0 km/h z17, 50 z16.2, 90 z15.6, 130+ z15). Eased toward that by at most
// (up to 20 km/h z18, 50 z17.3, 90 z16.3, 120+ z15.6). Eased toward that by at most
// 0.15 a fix and ignored within 0.25, so speed jitter doesn't pump the map.
// A hand zoom pauses the follow; on resuming it eases back.
export function autoZoom(current, speed) {
const target = Math.min(17, Math.max(15, 17 - speed * 3.6 * 0.0154));
const target = Math.max(15.5, 18 - Math.max(0, speed * 3.6 - 20) * 0.024);
const diff = target - current;
if (Math.abs(diff) < 0.25) return null;
return current + Math.sign(diff) * Math.min(Math.abs(diff), 0.15);