Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: load map with token #642

Merged
merged 1 commit into from
Dec 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/findbobastore/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default async function Home() {
const mapboxToken = process.env.NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN
return (
<main className="relative w-full h-screen">
<div className="absolute top-4 left-4 z-10 bg-slate-900/80 px-4 py-2 rounded-lg">
<div className="absolute top-4 left-4 z-10 bg-slate-900/50 px-4 py-2 rounded-lg">
<h1 className="text-xl font-bold text-white">Find Boba Store</h1>
</div>
{mapboxToken && <MapContainer token={mapboxToken} />}
Expand Down
6 changes: 3 additions & 3 deletions apps/findbobastore/src/components/map-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ function MapOverlay({ store }: { store: BobaStore | null }) {
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: 20 }}
className={cn(
'absolute bottom-4 left-4 p-4 bg-slate-900/90 rounded-lg shadow-lg',
'absolute bottom-4 left-4 p-4 bg-slate-900/40 rounded-lg shadow-lg',
'backdrop-blur-sm border border-slate-800',
'max-w-sm w-full z-10',
)}
Expand All @@ -238,7 +238,6 @@ function MapOverlay({ store }: { store: BobaStore | null }) {
}

export function MapView({ token }: { token: string }) {
mapboxgl.accessToken = token
const mapContainer = useRef<HTMLDivElement>(null)
const map = useRef<mapboxgl.Map | null>(null)
const [selectedStore, setSelectedStore] = useState<BobaStore | null>(null)
Expand Down Expand Up @@ -328,6 +327,7 @@ export function MapView({ token }: { token: string }) {
center: location,
zoom: 12,
maxZoom: 15,
accessToken: token,
})

map.current.on('load', () => {
Expand Down Expand Up @@ -367,7 +367,7 @@ export function MapView({ token }: { token: string }) {
trackUserLocation: true,
}),
)
}, [getUserLocation, clearMarkers, addUserLocationMarker, addBobaMarkers])
}, [getUserLocation, clearMarkers, addUserLocationMarker, addBobaMarkers, token])

useEffect(() => {
if (!map.current) {
Expand Down