diff --git a/src/components/map/places-map.tsx b/src/components/map/places-map.tsx index f337cfa..a4b3b55 100644 --- a/src/components/map/places-map.tsx +++ b/src/components/map/places-map.tsx @@ -61,7 +61,8 @@ export function PlacesMap({ places }: PlacesMapProps) { const [debouncedQuery, setDebouncedQuery] = React.useState(""); const [focusId, setFocusId] = React.useState(() => { if (typeof window === "undefined") return null; - return parseMapState(window.location.search).placeId ?? null; + const id = parseMapState(window.location.search).placeId ?? null; + return id && places.some((place) => place.id === id) ? id : null; }); // A viewport in the URL restores that exact center/zoom on load instead of // fitting all places; it is then kept in sync as the user pans (see #118).