Select to view content in your preferred language

Zoom to point

1250
10
01-06-2012 08:43 AM
ReneeMaxwell
Occasional Contributor
I'm seeing a problem with the centerAndZoom method for the map. The code is pretty straightforward:

map.centerAndZoom(pt, 0.1);


But instead of zooming in, it zooms OUT, regardless of the map scale prior to calling the method.

The map includes a base map that is an ArcGISDynamicMapServiceLayer, overlayed with several editable FeatureLayers.

This used to work for me but for some reason it started behaving strangely and I'm not sure what's different. It behaves the same in versions 2.5 and 2.6.
0 Kudos
10 Replies
ReneeMaxwell
Occasional Contributor
That brings to mind another issue I've had with changing the map extent. It seems that if I add a lot of graphic points to the map, whenever I change the extent programmatically the map will either be blurred, or it will not render completely. It will zoom out to the correct extent, but the only area that renders is the previous extent (but at the new scale), the rest of the map simply doesn't draw.
0 Kudos
SusanCarlson
New Contributor III
Same issue. I'm trying to centerAndZoom on a dynamic map service and regardless of what value I use for factor it zooms out twice as far (2.0).
0 Kudos
DominickCisson
Occasional Contributor
Same issue. I'm trying to centerAndZoom on a dynamic map service and regardless of what value I use for factor it zooms out twice as far (2.0).


Same issue as well... map.centerAndZoom() seems to zoom out 2x no matter what I put into it.  This bug was introduced at 2.6... If I revert back to 2.5, it goes away.
0 Kudos
AndrewEnglar
New Contributor
I've also now experienced this issue, and it's still broken in 2.8 as well.
0 Kudos
JeffPace
MVP Alum
I never really had alot of luck with center and zoom.  I prefer to called setExtent explicitly.

do you get the same error with

map.setExtent(map.extent.centerAt(pt);
map.setExtent(map.extent.expand(0.1));


if you do it this way it also explicity says use factor and cant be misinterpreted as a level from tiled (if you use a tiled basemap from the gallery or AGO, for example)
0 Kudos
derekswingley1
Frequent Contributor II
I've also now experienced this issue, and it's still broken in 2.8 as well.


Can you post your code to reproduce?
0 Kudos
DominickCisson
Occasional Contributor
This is still broken at 3.0.  There is a bug on file for this issue, NIM079613 (http://support.esri.com/en/bugs/nimbus/TklNMDc5NjEz), but it is set to medium, and doesn't appear to be on anyone's radar at esri. :confused:

   I did have some success with jeff.pace's workaround, though running

    map.setExtent(map.extent.centerAt(pt);
    map.setExtent(map.extent.expand(0.1));

   back-to-back didn't work for me.  The map would zoom in or zoom out, but not center on the point.  It's almost like the second command was getting called before the first even had a chance to finish.  I added a map.onPanEnd listener, split the two commands, and put the expand command inside the listener, so it doesn't fire until the pan is complete.  It works now, though the animation is different now... When a user double-clicks to zoom in or out, the map first pans to the point, and then zooms in or out
0 Kudos
DonKang
New Contributor III
I have the same issue. 3.0
This is posting by Kelly Hutchinson at ESRI found in another posting.

You can use esri.geometry.geographicToWebMercator to convert the geographic coords to web mercator. So if you switch your code to something like this it should zoom to the correct location:

I wonder if centerAndZoom only works for geographic coords using Lat and Long.

Don
0 Kudos
DominickCisson
Occasional Contributor
FWIW, the centerAndZoom bug appears to have been resolved in 3.2.  It can be used again without issue.

Huzzah!
0 Kudos