Add user location marker to brewery map, Add beer sec. for brewery posts

This commit is contained in:
Aaron William Po
2023-05-01 23:09:50 -04:00
parent f3d471be4c
commit d20ab0fd1f
10 changed files with 363 additions and 21 deletions

View File

@@ -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"