How can I check whether Google Maps is fully loaded?

This was bothering me for a while with GMaps v3.

I found a way to do it like this:

google.maps.event.addListenerOnce(map, 'idle', function(){
    // do something only the first time the map is loaded
});

The “idle” event is triggered when the map goes to idle state – everything loaded (or failed to load). I found it to be more reliable then tilesloaded/bounds_changed and using addListenerOnce method the code in the closure is executed the first time “idle” is fired and then the event is detached.

See also the events section in the Google Maps Reference.

Leave a Comment