generated from taylorbryant/gatsby-starter-tailwind
-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
viet nguyen
committed
Feb 26, 2024
1 parent
dc49346
commit 4b804da
Showing
9 changed files
with
111 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use client' | ||
import { useEffect, useState } from 'react' | ||
import { GlobalMap } from '@/components/maps/GlobalMap' | ||
|
||
export const FullScreenMap: React.FC = () => { | ||
const [initialCenter, setInitialCenter] = useState<[number, number] | undefined>(undefined) | ||
|
||
useEffect(() => { | ||
getVisitorLocation().then((visitorLocation) => { | ||
if (visitorLocation != null) { | ||
setInitialCenter([visitorLocation.longitude, visitorLocation.latitude]) | ||
} | ||
}).catch(() => { | ||
console.log('Unable to determine user\'s location') | ||
}) | ||
}, []) | ||
|
||
return ( | ||
<GlobalMap | ||
showFullscreenControl={false} | ||
initialCenter={initialCenter} | ||
/> | ||
) | ||
} | ||
|
||
const getVisitorLocation = async (): Promise<{ longitude: number, latitude: number } | undefined> => { | ||
try { | ||
const res = await fetch('/api/geo') | ||
return await res.json() | ||
} catch (err) { | ||
console.log('ERROR', err) | ||
return undefined | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,13 @@ | ||
import { GlobalMap } from '@/components/maps/GlobalMap' | ||
import { ProfileMenu } from '../components/ProfileMenu' | ||
import { FullScreenMap } from '../components/FullScreenMap' | ||
|
||
export const dynamic = 'force-dynamic' | ||
|
||
export default async function MapPage (): Promise<any> { | ||
return ( | ||
<div className='w-full h-full'> | ||
<ProfileMenu /> | ||
<GlobalMap | ||
showFullscreenControl={false} | ||
/> | ||
<FullScreenMap /> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.