From 7dcd89fb71c12aead95d9fdebf97e4d487326537 Mon Sep 17 00:00:00 2001 From: Maurice Date: Sun, 29 Mar 2026 16:55:27 +0200 Subject: [PATCH] =?UTF-8?q?fix:=20pan=20to=20clicked=20marker=20without=20?= =?UTF-8?q?zoom=20reset=20=E2=80=94=20closes=20#86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/components/Map/MapView.tsx | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/client/src/components/Map/MapView.tsx b/client/src/components/Map/MapView.tsx index fa26706..6ca4238 100644 --- a/client/src/components/Map/MapView.tsx +++ b/client/src/components/Map/MapView.tsx @@ -107,20 +107,14 @@ function SelectionController({ places, selectedPlaceId, dayPlaces, paddingOpts } useEffect(() => { if (selectedPlaceId && selectedPlaceId !== prev.current) { - // Fit all day places into view (so you see context), but ensure selected is visible - const toFit = dayPlaces.length > 0 ? dayPlaces : places.filter(p => p.id === selectedPlaceId) - const withCoords = toFit.filter(p => p.lat && p.lng) - if (withCoords.length > 0) { - try { - const bounds = L.latLngBounds(withCoords.map(p => [p.lat, p.lng])) - if (bounds.isValid()) { - map.fitBounds(bounds, { ...paddingOpts, maxZoom: 16, animate: true }) - } - } catch {} + // Pan to the selected place without changing zoom + const selected = places.find(p => p.id === selectedPlaceId) + if (selected?.lat && selected?.lng) { + map.panTo([selected.lat, selected.lng], { animate: true }) } } prev.current = selectedPlaceId - }, [selectedPlaceId, places, dayPlaces, paddingOpts, map]) + }, [selectedPlaceId, places, map]) return null }