My favorites | Sign in
Project Home Issues
New issue   Search
for
  Advanced search   Search tips   Subscriptions
Issue 1399: maps zoom_changed event fires before bounds have been recalculated
24 people starred this issue and may be notified of changes. Back to list
Status:  Fixed
Owner:  ----
Closed:  Sep 2012


Sign in to add a comment
 
Reported by [email protected], Jun 16, 2009
if you want to find the bound after a zoom change doing the following

google.maps.event.addListener(map,'zoom_changed',function (event) {
    console.log(map.get_bounds());
  });

will return the bounds before the zoom change rather than after
Jun 16, 2009
#1 [email protected]
not sure if this is a bug or the intended behaviour 
this is a way to get the new bounds


  zoomChangeListener = google.maps.event.addListener(map,'zoom_changed',function (event) {
    zoomChangeBoundsListener = google.maps.event.addListener(map,'bounds_changed',function (event) {  
      console.log(map.get_bounds());
      google.maps.event.removeListener(zoomChangeBoundsListener);
    });
  });
Jun 18, 2009
#2 pamela.fox
Not sure- I'll discuss with team.
Status: Acknowledged
Labels: Internal-1925758
Nov 21, 2009
#3 [email protected]
Quoted from https://code.google.com/apis/maps/documentation/v3/events.html :

Note:  If you are trying to detect a change in the viewport, be sure to use the
specific bounds_changed event rather than constituent zoom_changed and center_changed
events. Because the Maps API fires these latter events independently, getBounds() may
not report useful results until after the viewport has authoritatively changed. If
you wish to getBounds() after such an event, be sure to listen to the bounds_changed
event instead.

It seems like this is the intended behaviour  (at least in  API V3)
Dec 7, 2009
#4 [email protected]
I believe this issue has been fixed a while ago by adding an 'idle' event for the Map
object.
Status: Fixed
Labels: Fixed-16
Nov 23, 2011
#5 [email protected]
I don't understand comment #4. The issue is NOT fixed, it's still present. 

This is clearly a bug, because the map is in inconsistent state when zoom_changed handler is called - the zoom is the new one, but the bounds are still the old ones!!! This should never happen!

Thanks for workaround in comment #1, this seems to be the only way how one can get the bounds in the zoom_changed event. But this is not a clean way, the issue should be fixed!!!


Nov 23, 2011
#6 [email protected]
ad comment #3 - using bounds_changed event instead of zoom_changed in this case is nonsense. It will fire at any occasion when bounds are changed, but here we are only interested in cases when the zoom is changed!
Apr 26, 2012
#7 [email protected]
ad comment #5 totally agree, cause bounds_changed event is fired after a zoom_changed event :( so that there is no way to get correct bounds when the zoom_changed occurs.
bounds_changed is not handy event because it is fired whenever viewport has changed and a user is moving map all around without releasing the drag mode. In this state (while dragging) I'm not interested in bounds_chaned event. Please can anyone confirm that this is really a bug? IMHO it is :(
Apr 26, 2012
#8 [email protected]
I'm using idle event that is sufficient for my needs and this is the only event I use instead of both the dragend and zoom_chaned events.
May 22, 2012
#9 [email protected]
#8: idle fires when you resize map, while zoom_changed/dragend do not.
May 22, 2012
#10 [email protected]
(No comment was entered for this change.)
Status: Confirmed
Labels: -Internal-1925758 -Fixed-16 Internal-6533802
Sep 2, 2012
#11 [email protected]
(No comment was entered for this change.)
Status: Fixed
Jun 17, 2015
#12 [email protected]
Status: Fixed? The issue is not fixed, it's still present.
Oct 1, 2015
Project Member #13 [email protected]
 Issue 2850  has been merged into this issue.
Sign in to add a comment

Powered by Google Project Hosting