Skip to content

GoogleMapApiLoader

<GoogleMapApiLoader /> component is used for load the Google Maps API.

Basic Example

function App() {
return (
<Suspense fallback={...}>
<GoogleMapApiLoader
apiKey='YOUR_API_KEY'
suspense
>
{/* You can create map here */}
<MyMap />
</GoogleMapApiLoader>
</Suspense>
);
}
// or
function App() {
const loadingStatus = useApiLoadingStatus();
return (
<GoogleMapApiLoader
apiKey='YOUR_API_KEY'
>
{
loadingStatus === LoadingStatus.SUCCESS && (
// You can create map here
<MyMap />
)
}
</GoogleMapApiLoader>
);
}

Props

PropsTypeDescription
apiKeystringYour Google Maps API Key
suspensebooleanflag for using suspense
onSuccess(core: google.maps.CoreLibrary) => voidcallback for loading success
onFailure(reason: unknown) => voidcallback for loading failure
vstringPlease refer to the official documentation.
librariesstring | string[]
languagestring
regionstring
authReferrerPolicystring

Loading Status

You can use useApiLoadingStatus hooks to get the loading status.

Legacy script loading tag

If you’re using the legacy script loading tag, you don’t need to use this component.