Fix pitch persistence to prevent view drift on reload

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 <noreply@anthropic.com>
This commit is contained in:
Your Name 2025-12-22 22:59:30 -05:00
parent d845fd7a5a
commit f22b9dfe06
1 changed files with 9 additions and 3 deletions

View File

@ -82,7 +82,8 @@ export function useMapCore(theme) {
if (typeof v.lat === "number" && typeof v.lon === "number" && typeof v.zoom === "number") { if (typeof v.lat === "number" && typeof v.lon === "number" && typeof v.zoom === "number") {
map.setCenter([v.lon, v.lat]); map.setCenter([v.lon, v.lat]);
map.setZoom(v.zoom); 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; hadLastView = true;
} }
} }
@ -106,7 +107,7 @@ export function useMapCore(theme) {
map.on("load", () => { map.on("load", () => {
setViewParams(getViewFromMap(map)); 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", () => { map.on("moveend", () => {
@ -116,7 +117,12 @@ export function useMapCore(theme) {
const center = vp.center; const center = vp.center;
localStorage.setItem( localStorage.setItem(
LAST_VIEW_KEY, 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 {} } catch {}
}); });