From a75885ca76cc1549ae20ca20408559a552b5d899 Mon Sep 17 00:00:00 2001 From: Padreug Date: Mon, 20 Apr 2026 15:46:39 +0200 Subject: [PATCH] Only fit map bounds on initial load, not on every activity update Prevents the map from resetting zoom/pan when new activities stream in from relays. Users can now freely zoom and pan without being snapped back to the world view. Co-Authored-By: Claude Opus 4.6 (1M context) --- src/modules/activities/components/ActivityMap.vue | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/modules/activities/components/ActivityMap.vue b/src/modules/activities/components/ActivityMap.vue index 9448bde..06f6a69 100644 --- a/src/modules/activities/components/ActivityMap.vue +++ b/src/modules/activities/components/ActivityMap.vue @@ -15,6 +15,7 @@ const router = useRouter() const mapContainer = ref(null) let map: L.Map | null = null let markerGroup: L.LayerGroup | null = null +let hasFittedBounds = false // Fix Leaflet default icon paths (broken by bundlers) const defaultIcon = L.icon({ @@ -90,8 +91,9 @@ function updateMarkers() { markerGroup.addLayer(marker) } - // Fit bounds if there are markers - if (geoActivities.length > 0) { + // Fit bounds only on first load, not when new activities stream in + if (!hasFittedBounds && geoActivities.length > 0) { + hasFittedBounds = true const bounds = L.latLngBounds( geoActivities.map(a => [a.coordinates!.lat, a.coordinates!.lng] as L.LatLngTuple) )