diff --git a/src/components/map/MapInteraction.js b/src/components/map/MapInteraction.js index ca95221..975bf59 100644 --- a/src/components/map/MapInteraction.js +++ b/src/components/map/MapInteraction.js @@ -74,9 +74,11 @@ function MapInteraction({ const stageTranslateRef = useRef({ x: 0, y: 0 }); // Reset transform when map changes + const previousMapIdRef = useRef(); useEffect(() => { const layer = mapLayerRef.current; - if (map && layer && !mapLoaded) { + const previousMapId = previousMapIdRef.current; + if (map && layer && previousMapId !== map.id) { const mapHeight = stageWidthRef.current * (map.height / map.width); const newTranslate = { x: 0, @@ -89,7 +91,8 @@ function MapInteraction({ setStageScale(1); } - }, [map, mapLoaded]); + previousMapIdRef.current = map && map.id; + }, [map]); const pinchPreviousDistanceRef = useRef(); const pinchPreviousOriginRef = useRef();