From f22b9dfe06184a598137366d0b3e08c216ae046f Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 22 Dec 2025 22:59:30 -0500 Subject: [PATCH] Fix pitch persistence to prevent view drift on reload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Problem: Map pitch was always forced to 45° instead of being restored, causing the view to appear shifted higher after each reload - Save current pitch value to localStorage on moveend - Restore pitch from localStorage on map initialization - Remove forced pitch=45 on map load event - Default to 45° only if no saved pitch exists This prevents the map from drifting north/higher with each page reload while maintaining the 3D tilt effect. Auth: Session persistence already implemented via localStorage tokens - Tokens are saved in localStorage and restored on mount - Auto-refresh runs every 30s to keep session alive - If session issues persist, check browser console for specific errors 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- src/components/Map/useMapCore.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/components/Map/useMapCore.js b/src/components/Map/useMapCore.js index 6b70589..625fbc3 100644 --- a/src/components/Map/useMapCore.js +++ b/src/components/Map/useMapCore.js @@ -82,7 +82,8 @@ export function useMapCore(theme) { if (typeof v.lat === "number" && typeof v.lon === "number" && typeof v.zoom === "number") { map.setCenter([v.lon, v.lat]); map.setZoom(v.zoom); - map.setPitch(45); // tilt 3D forcé + // Restore pitch from storage, default to 45 if not saved + map.setPitch(typeof v.pitch === "number" ? v.pitch : 45); hadLastView = true; } } @@ -106,7 +107,7 @@ export function useMapCore(theme) { map.on("load", () => { setViewParams(getViewFromMap(map)); - map.setPitch(45); // tilt 3D forcé au load + // Don't force pitch on load - let it stay as configured }); map.on("moveend", () => { @@ -116,7 +117,12 @@ export function useMapCore(theme) { const center = vp.center; localStorage.setItem( LAST_VIEW_KEY, - JSON.stringify({ lat: center[1], lon: center[0], zoom: map.getZoom() }) + JSON.stringify({ + lat: center[1], + lon: center[0], + zoom: map.getZoom(), + pitch: map.getPitch() + }) ); } catch {} });