Google Maps Api v3 - getBounds is undefined

前端 未结 5 1693
春和景丽
春和景丽 2020-11-30 21:41

I\'m switching from v2 to v3 google maps api and got a problem with gMap.getBounds() function.

I need to get the bounds of my map after its initializati

5条回答
  •  旧巷少年郎
    2020-11-30 22:30

    I was saying Salman's solution is better because the idle event is called earlier than the tilesloaded one, since it waits for all the tiles to be loaded. But on a closer look, it seems bounds_changed is called even earlier and it also makes more sense, since you're looking for the bounds, right? :)

    So my solution would be:

    google.maps.event.addListenerOnce(gMap, 'bounds_changed', function(){
        alert(this.getBounds());
    });
    

提交回复
热议问题