-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGoogleMap.jsx
More file actions
45 lines (40 loc) · 969 Bytes
/
GoogleMap.jsx
File metadata and controls
45 lines (40 loc) · 969 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { Spinner } from "@chakra-ui/react";
// import { Inter } from "@next/font/google";
import { GoogleMap, MarkerF, useLoadScript } from "@react-google-maps/api";
import { useMemo } from "react";
// const inter = Inter({ subsets: ["latin"] });
/**
*
* @param props
*/
export default function Map(props) {
const { isLoaded } = useLoadScript({
googleMapsApiKey: process.env.NEXT_PUBLIC_GOOGLE_MAPS_API_KEY,
});
if (!isLoaded) return <Spinner />;
return <GMap {...props} />;
}
/**
*
* @param root0
* @param root0.width
* @param root0.height
* @param root0.zoom
* @param root0.lat
* @param root0.lng
*/
function GMap({ width = "100%", height = "100%", zoom = 12, lat, lng }) {
const center = useMemo(
() => ({ lat: parseFloat(lat), lng: parseFloat(lng) }),
[lat, lng]
);
return (
<GoogleMap
zoom={zoom}
center={center}
mapContainerStyle={{ width: width, height: height }}
>
<MarkerF position={center} />
</GoogleMap>
);
}