Skip to content

Commit

Permalink
fix: load map with token (#642)
Browse files Browse the repository at this point in the history
  • Loading branch information
gregkonush authored Dec 24, 2024
1 parent e36465e commit 23c734a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit 23c734a

Please sign in to comment.