Imagine you are going to a web site with an empty cache.
开发者_如何学PythonIn Google Maps API v3, what's the earliest event that will be triggered to inform me the bounds of the maps on initial load?
In Google Maps v2 it was the 'loaded' event; however, this event is not present in v3 of the API.
Would it be the 'bound_changed' event for v3 of the API? If not, does some other event exist that get's fired sooner than bound_changed that will allow me to gain access to the current maps bounds?
Google Maps will load a blank screen if you don't set the center and zoom level.
There is no load event, however when you instantiate the Map object, you can fire an event at this point, if that is what you are looking for.
I think "bounds_changed" is probably your best bet, because that is guaranteed that bounds_changed actually set the proper values, although the following events have been fired in this order.
center_changed, zoom_changed, bounds_changed, idle, tilesloaded
Still it makes sense that bounds_changed is where you would pick it up, because google sets the center, sets the zoom level, and determines the bounds.
精彩评论