Possible bug with map.centerAndZoom

558
2
11-07-2012 12:32 PM
RexBradford
New Contributor II
I have a repeatable bug in an app, where in certain circumstances Internet Explorer 9 fails to map.centerAndZoom properly.  Other browsers I've tested (Firefox, Safari, Chrome, Opera) are fine.  The condition seems to be when the starting point has essentially the same longitude as the desired destination (doesn't need to be exact).  In this scenario, but only the first time (I swear), the map just zooms straight in without adjusting lat or lon.  Both the map and the desired destination are Web Mercator spatial refs (wkid: 102100).

In other words, the bug is triggered by code kind of like so, where xnew, ynew, and zoomLevel are supplied (and where xnew is not much different from current center x of the map):

        var zoomLevel = 4;   // or whatever, zooming in in this case
        var WMRef = new esri.SpatialReference({wkid: 102100});
 var newCenter = new esri.geometry.Point(xnew, ynew, WMRef);
 map.centerAndZoom(newCenter, zoomLevel);


in IE9 and no other browser, first execution will just zoom straight in with no panning at all.  I do not have an isolated 1-page for this, no.

If I put the line:
        xnew += 1000000"

before the code above, then the zoomcenter works (though zoomcenters to the wrong spot of course), because the longitude is apparently different enough to cure the bug.

Anybody seen this?

Rex Bradford
Direct Relief International
0 Kudos
2 Replies
RexBradford
New Contributor II
Also if there are any hooks for troubleshooting this kind of thing....

Rex Bradford
Direct Relief International
0 Kudos
RexBradford
New Contributor II
In case anyone's following this and interested, the "same longitude" thing was a red herring. The real clue was "first time", because i n the real app the first time this zoom happens I also turn on another layer and their markers and other stuff like that.  I haven't figured out the details, but delaying that layer creation until the end of the zoom cured the problem.  I don't know why only IE9 is unhappy with creating the layer while zooming and not other browsers, but anyhow that's the area where the issue lies.

Rex Bradford
Mary Ferrell Foundation
0 Kudos