mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
Add user location marker to brewery map, Add beer sec. for brewery posts
This commit is contained in:
@@ -13,6 +13,7 @@ import DBClient from '@/prisma/DBClient';
|
||||
import LocationMarker from '@/components/ui/LocationMarker';
|
||||
import Link from 'next/link';
|
||||
import Head from 'next/head';
|
||||
import useGeolocation from '@/hooks/useGeolocation';
|
||||
|
||||
type MapStyles = Record<'light' | 'dark', `mapbox://styles/mapbox/${string}`>;
|
||||
|
||||
@@ -61,7 +62,7 @@ const BreweryMapPage: NextPage<BreweryMapPageProps> = ({ breweries }) => {
|
||||
setPopupInfo(brewery);
|
||||
}}
|
||||
>
|
||||
<LocationMarker />
|
||||
<LocationMarker size="md" color="blue" />
|
||||
</Marker>
|
||||
);
|
||||
})}
|
||||
@@ -69,6 +70,19 @@ const BreweryMapPage: NextPage<BreweryMapPageProps> = ({ breweries }) => {
|
||||
),
|
||||
[breweries],
|
||||
);
|
||||
|
||||
const { coords, error } = useGeolocation();
|
||||
|
||||
const userLocationPin = useMemo(
|
||||
() =>
|
||||
coords && !error ? (
|
||||
<Marker latitude={coords.latitude} longitude={coords.longitude}>
|
||||
<LocationMarker size="lg" color="red" />
|
||||
</Marker>
|
||||
) : null,
|
||||
[coords, error],
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
<Head>
|
||||
@@ -90,6 +104,7 @@ const BreweryMapPage: NextPage<BreweryMapPageProps> = ({ breweries }) => {
|
||||
<NavigationControl position="top-left" />
|
||||
<ScaleControl />
|
||||
{pins}
|
||||
{userLocationPin}
|
||||
{popupInfo && (
|
||||
<Popup
|
||||
anchor="bottom"
|
||||
|
||||
Reference in New Issue
Block a user