diff --git a/src/app/student/map/_components/MapComponent.tsx b/src/app/student/map/_components/MapComponent.tsx index 46653a6..f6f7e59 100644 --- a/src/app/student/map/_components/MapComponent.tsx +++ b/src/app/student/map/_components/MapComponent.tsx @@ -6,6 +6,7 @@ import { Location, LocationId } from "@/app/student/map/lib/locations" import { useFeatureState } from "@/components/shared/hooks/useFeatureState" import { useGeoJsonPlanData } from "@/components/shared/hooks/useGeoJsonPlanData" import "maplibre-gl/dist/maplibre-gl.css" +import { useSearchParams } from "next/navigation" import { useEffect, useMemo, useRef, useState } from "react" import { Layer, @@ -47,6 +48,8 @@ export function MapComponent({ initialView: { longitude: number; latitude: number; zoom: number } filteredBoothIds: BoothID[] }) { + const searchParams = useSearchParams() + const mapRef = useRef(null) const [mapZoom, setMapZoom] = useState(initialView.zoom) @@ -56,15 +59,21 @@ export function MapComponent({ const [preLocationId, setPreLocationId] = useState(location.id) // Fly to location center on change useEffect(() => { + const hasSearchParams = searchParams.has("lat") || searchParams.has("lng") const { longitude, latitude, zoom } = location.center const timeout = setTimeout(() => { - mapRef.current?.flyTo({ - center: [longitude, latitude], - zoom - }) + if (!hasSearchParams) { + mapRef.current?.flyTo({ + center: [longitude, latitude], + zoom + }) + } + // Remove the search params + const { pathname } = window.location + window.history.replaceState(null, "", pathname) }, 300) - return () => clearTimeout(timeout) setMarkerScale(0.6) + return () => clearTimeout(timeout) }, [location]) useEffect(() => { diff --git a/src/app/student/map/data/booths.json b/src/app/student/map/data/booths.json index 8b27571..5e6066b 100644 --- a/src/app/student/map/data/booths.json +++ b/src/app/student/map/data/booths.json @@ -70,7 +70,7 @@ "properties": { "id": 5, "location": "nymble/2", - "exhibitorId": 1536 + "exhibitorId": 1543 }, "geometry": { "coordinates": [ diff --git a/src/app/student/map/lib/locations.ts b/src/app/student/map/lib/locations.ts index eda4971..48e876c 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-floor2", + label: "Nymble Floor2", center: nymbleCenter }, { id: "nymble/3", - label: "Nymble-floor3", + label: "Nymble Floor3", center: nymbleCenter }, {