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(journey): guard photo layer draw against map with no view yet Public journey pages ≥1024px render the sticky sidebar map immediately with photos, before the deferred fitBounds/setView lands, causing latLngToContainerPoint to throw "Set map center and zoom first."

xviload6e51c574af
diff --git a/client/src/components/Journey/JourneyMap.tsx b/client/src/components/Journey/JourneyMap.tsx
index a11828db5..28d230dff 100644
--- a/client/src/components/Journey/JourneyMap.tsx
+++ b/client/src/components/Journey/JourneyMap.tsx
@@ -405,6 +405,16 @@ function JourneyMap(
photoLayerRef.current = null
if (!photos?.length) return
+ // The initial view (setView/fitBounds) is set on a deferred rAF in the
+ // map-build effect above, so this can run before the map has a center/zoom
+ // — latLngToContainerPoint throws in that window. Skip; the moveend/zoomend
+ // listener below redraws once the deferred view lands.
+ try {
+ map.getCenter()
+ } catch {
+ return
+ }
+
const group = L.layerGroup()
for (const cluster of clusterPhotos(map, photos)) {
const marker = L.marker([cluster.lat, cluster.lng], {