Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Map v3 Map loaded event [duplicate]

Is there any listener to handle map completely loaded?

In my case, I need to get bounds from map, so I've done it this way:

google.maps.event.addListener(this.map, "bounds_changed", this.mapLoaded);

mapLoaded: function() {
    google.maps.event.clearListeners(this.map, "bounds_changed");

    var bounds = this.map.getBounds();

    this.collection.setBounds(bounds.getNorthEast(), bounds.getSouthWest());
    this.collection.fetch();
},

Is there any not-hacking way?

like image 335
skayred Avatar asked Dec 30 '11 07:12

skayred


2 Answers

Try something like:

google.maps.event.addListenerOnce(map, 'idle', function(){
    //loaded fully
});
like image 159
Sudhir Bastakoti Avatar answered Nov 10 '22 06:11

Sudhir Bastakoti


How about the tilesloadedevent?

google.maps.event.addListener(map, 'tilesloaded', function() {
  // Visible tiles loaded!
});
like image 39
Ash Avatar answered Nov 10 '22 05:11

Ash