feat(maps): init google maps

This commit is contained in:
2021-01-21 21:17:12 +00:00
parent 9907861e00
commit 3e5c6b16a0
7 changed files with 65 additions and 1 deletions

33
src/components/map.js Normal file
View File

@@ -0,0 +1,33 @@
import React from "react";
import { useStaticQuery, graphql } from "gatsby";
import { GoogleApiWrapper, Map } from "google-maps-react";
const MapContainer = ({ children, google, height = "300px", ...other }) => (
<Map
style={{ height }}
containerStyle={{ position: "relative", height }}
google={google}
{...other}
>
{children}
</Map>
);
export default function CustomMap({ ...other }) {
const data = useStaticQuery(graphql`
query {
site {
siteMetadata {
secrets {
GMAPS_APIKEY
}
}
}
}
`);
const Wrapper = GoogleApiWrapper({
apiKey: data.site.siteMetadata.secrets.GMAPS_APIKEY
})(MapContainer);
return <Wrapper {...other} />;
}