Categories
JavaScript Answers

How to check whether Google Maps is fully loaded with JavaScript?

Spread the love

To check whether Google Maps is fully loaded with JavaScript, we call addListenerOnce to listen for the first idle event triggered.

For instance, we write

google.maps.event.addListenerOnce(map, "idle", () => {
  // ...
});

to call addListenerOnce to listen for the first idle event triggered by calling it with the map, 'idle', and the idle event handler callback.

If the callback is called, that means the Google Map is fully loaded.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *