Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix: pan to clicked marker without zoom reset — closes #86

Maurice7dcd89fb71c1
diff --git a/client/src/components/Map/MapView.tsx b/client/src/components/Map/MapView.tsx
index fa267063e..6ca42384a 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
}