谷歌地图v3地图加载事件

43

有没有监听器可以处理地图完全加载?

在我的情况下,我需要从地图中获取范围,所以我是这样做的:

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();
},

有没有非黑客方式?

2个回答

89

尝试类似以下的方式:

google.maps.event.addListenerOnce(map, 'idle', function(){
    //loaded fully
});

19

tilesloaded事件怎么样?

google.maps.event.addListener(map, 'tilesloaded', function() {
  // Visible tiles loaded!
});

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接