diff --git a/frontend/src/pages/TourNavigationPage.tsx b/frontend/src/pages/TourNavigationPage.tsx index 91568ce..b0de235 100644 --- a/frontend/src/pages/TourNavigationPage.tsx +++ b/frontend/src/pages/TourNavigationPage.tsx @@ -39,7 +39,7 @@ const MapRotationHandler = ({ rotation }: { rotation: number }) => { if (rotation === 0) { cumulativeRotationRef.current = 0; prevRotationRef.current = 0; - container.style.transform = 'rotate(0deg) scale(1)'; + container.style.transform = ''; return; } @@ -69,20 +69,12 @@ const CompassInteractionDetector = ({ return null; }; -const MapRefSetter = ({ mapRef }: { mapRef: React.MutableRefObject }) => { - const map = useMap(); - useEffect(() => { - mapRef.current = map; - }, [map, mapRef]); - return null; -}; - const MapSizeHandler = () => { const map = useMap(); useEffect(() => { const timer = setTimeout(() => { map.invalidateSize(); - }, 0); + }, 100); return () => clearTimeout(timer); }, [map]); return null; @@ -93,26 +85,12 @@ export const TourNavigationPage: React.FC = ({ tourId, const [currentHeading, setCurrentHeading] = useState(0); const [routeGeometry, setRouteGeometry] = useState<[number, number][] | null>(null); const [error, setError] = useState(null); - const [viewportHeight, setViewportHeight] = useState(() => { - return Math.max(document.documentElement.clientHeight, window.innerHeight || 0); - }); + const [mapReady, setMapReady] = useState(false); const mapRef = useRef(null); const watchIdRef = useRef(null); const fetchLockRef = useRef(false); - useEffect(() => { - const handleResize = () => { - setViewportHeight(Math.max(document.documentElement.clientHeight, window.innerHeight || 0)); - }; - window.addEventListener('resize', handleResize); - window.addEventListener('orientationchange', handleResize); - return () => { - window.removeEventListener('resize', handleResize); - window.removeEventListener('orientationchange', handleResize); - }; - }, []); - const originLat = routeData?.origin?.lat; const originLng = routeData?.origin?.lng; const destLat = routeData?.destination?.lat; @@ -226,7 +204,7 @@ export const TourNavigationPage: React.FC = ({ tourId, : [0, 0]; return ( -
+
-
+