From a43d9610fc3536116ba27d2304e46457ccea7676 Mon Sep 17 00:00:00 2001 From: AmiyaSX <2668590277@qq.com> Date: Wed, 13 Nov 2024 20:02:10 +0100 Subject: [PATCH] Fix flyto in mobile --- src/app/student/map/_components/MapComponent.tsx | 11 +++++++---- src/app/student/map/lib/locations.ts | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/app/student/map/_components/MapComponent.tsx b/src/app/student/map/_components/MapComponent.tsx index 9e4c2ad..17a36e0 100644 --- a/src/app/student/map/_components/MapComponent.tsx +++ b/src/app/student/map/_components/MapComponent.tsx @@ -54,10 +54,13 @@ export function MapComponent({ // Fly to location center on change useEffect(() => { const { longitude, latitude, zoom } = location.center - mapRef.current?.flyTo({ - center: [longitude, latitude], - zoom: zoom - }) + const timeout = setTimeout(() => { + mapRef.current?.flyTo({ + center: [longitude, latitude], + zoom + }) + }, 300) + return () => clearTimeout(timeout) setMarkerScale(0.6) }, [location]) diff --git a/src/app/student/map/lib/locations.ts b/src/app/student/map/lib/locations.ts index 951ff3e..556941c 100644 --- a/src/app/student/map/lib/locations.ts +++ b/src/app/student/map/lib/locations.ts @@ -21,12 +21,12 @@ const libraryCenter = { export const locations: Location[] = [ { id: "nymble/2", - label: "Nymble - floor 2", + label: "Nymble-F2", center: nymbleCenter }, { id: "nymble/3", - label: "Nymble - floor 3", + label: "Nymble-F3", center: nymbleCenter }, {