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."
This commit is contained in:
xvilo
2026-09-05 22:07:13 +09:00
committed by Maurice
parent 523443f1d7
commit ea0589b21e
@@ -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], {