Check if map is loaded! #405
-
Is there a way to check if map is loaded? and till it loads I want to show a loading indicator. I am trying this : const onLoad = useCallback((map) => { |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Currently, you can only check if the Maps JavaScript API is loaded using the const MyMap = () => {
const [mapIsReady, setMapIsReady] = useState(false);
const handleTilesLoaded = useCallback(() => setMapIsReady(true), []);
return <>
<Map onTilesLoaded={handleTilesLoaded}>...</Map>
{!mapIsReady && <div className="loading-overlay"></div>}
</>;
}; |
Beta Was this translation helpful? Give feedback.
Currently, you can only check if the Maps JavaScript API is loaded using the
useApiIsLoaded
hook.If you want to wait until the map is fully rendered, you can use an overlay and the
tilesloaded
oridle
events, roughly like this: