Skip to content

Commit 9108125

Browse files
committed
Fix lat/lon param zoom in, booth fix and label fix
1 parent f16cff8 commit 9108125

File tree

3 files changed

+17
-8
lines changed

3 files changed

+17
-8
lines changed

src/app/student/map/_components/MapComponent.tsx

+14-5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Location, LocationId } from "@/app/student/map/lib/locations"
66
import { useFeatureState } from "@/components/shared/hooks/useFeatureState"
77
import { useGeoJsonPlanData } from "@/components/shared/hooks/useGeoJsonPlanData"
88
import "maplibre-gl/dist/maplibre-gl.css"
9+
import { useSearchParams } from "next/navigation"
910
import { useEffect, useMemo, useRef, useState } from "react"
1011
import {
1112
Layer,
@@ -47,6 +48,8 @@ export function MapComponent({
4748
initialView: { longitude: number; latitude: number; zoom: number }
4849
filteredBoothIds: BoothID[]
4950
}) {
51+
const searchParams = useSearchParams()
52+
5053
const mapRef = useRef<MapRef>(null)
5154

5255
const [mapZoom, setMapZoom] = useState(initialView.zoom)
@@ -56,15 +59,21 @@ export function MapComponent({
5659
const [preLocationId, setPreLocationId] = useState<LocationId>(location.id)
5760
// Fly to location center on change
5861
useEffect(() => {
62+
const hasSearchParams = searchParams.has("lat") || searchParams.has("lng")
5963
const { longitude, latitude, zoom } = location.center
6064
const timeout = setTimeout(() => {
61-
mapRef.current?.flyTo({
62-
center: [longitude, latitude],
63-
zoom
64-
})
65+
if (!hasSearchParams) {
66+
mapRef.current?.flyTo({
67+
center: [longitude, latitude],
68+
zoom
69+
})
70+
}
71+
// Remove the search params
72+
const { pathname } = window.location
73+
window.history.replaceState(null, "", pathname)
6574
}, 300)
66-
return () => clearTimeout(timeout)
6775
setMarkerScale(0.6)
76+
return () => clearTimeout(timeout)
6877
}, [location])
6978

7079
useEffect(() => {

src/app/student/map/data/booths.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"properties": {
7171
"id": 5,
7272
"location": "nymble/2",
73-
"exhibitorId": 1536
73+
"exhibitorId": 1543
7474
},
7575
"geometry": {
7676
"coordinates": [

src/app/student/map/lib/locations.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ const libraryCenter = {
2121
export const locations: Location[] = [
2222
{
2323
id: "nymble/2",
24-
label: "Nymble-floor2",
24+
label: "Nymble Floor2",
2525
center: nymbleCenter
2626
},
2727
{
2828
id: "nymble/3",
29-
label: "Nymble-floor3",
29+
label: "Nymble Floor3",
3030
center: nymbleCenter
3131
},
3232
{

0 commit comments

Comments
 (0)