Select to view content in your preferred language

centerAndZoom() Zooms all the way out

1310
3
Jump to solution
04-25-2013 06:28 AM
EdwardRozum
Occasional Contributor
Using the  3.3 compact javascript library, I have had an issue using center and zoom when my basemap is dynamic. When it is cached, it seems to work correctly. Has anyone seen this before?

var symbol = new esri.symbol.PictureMarkerSymbol('css/images/Pin.png', 32, 32);
    var point = esri.geometry.geographicToWebMercator(new esri.geometry.Point(attributes.long, attributes.lat));
    var graphic = new esri.Graphic(point, symbol, attributes, infoTemplate);

    //Add to map and zoom
    map.graphics.add(graphic);
    map.centerAndZoom(point, 9);
    map.infoWindow.setFeatures([graphic]);
0 Kudos
1 Solution

Accepted Solutions
ReneRubalcava
Esri Frequent Contributor
The Map::centerAndZoom method behaves differently based on your basemap data.
http://help.arcgis.com/EN/webapi/javascript/arcgis/jsapi/map.html#centerAndZoom
So in reference to the second argument in that function:
When using an ArcGISTiledMapServiceLayer, the map is zoomed to the level specified. When using a DynamicMapServiceLayer, the map is zoomed in or out by the specified factor. For example, use 0.5 to zoom in twice as far and 2.0 to zoom out twice as far.


So when you have a Tiled basemap and you use map.centerAndZoom(point, 9), it will zoom to the 9th level of your maps level of details.
When you have a dynamic basemap and use map.centerAndZoom(point, 9), you are zooming out by a factor of 9, that's global status.

So you'll want to adjust how you use it based on your basemap.

View solution in original post

0 Kudos
3 Replies
ReneRubalcava
Esri Frequent Contributor
The Map::centerAndZoom method behaves differently based on your basemap data.
http://help.arcgis.com/EN/webapi/javascript/arcgis/jsapi/map.html#centerAndZoom
So in reference to the second argument in that function:
When using an ArcGISTiledMapServiceLayer, the map is zoomed to the level specified. When using a DynamicMapServiceLayer, the map is zoomed in or out by the specified factor. For example, use 0.5 to zoom in twice as far and 2.0 to zoom out twice as far.


So when you have a Tiled basemap and you use map.centerAndZoom(point, 9), it will zoom to the 9th level of your maps level of details.
When you have a dynamic basemap and use map.centerAndZoom(point, 9), you are zooming out by a factor of 9, that's global status.

So you'll want to adjust how you use it based on your basemap.
0 Kudos
EdwardRozum
Occasional Contributor
Ok that makes sense to me. I'll adjust as needed. Thanks for the quick reply. I appreciate the help.
0 Kudos
JohnGravois
Deactivated User
perhaps you could mark Rene's post as an answer?
0 Kudos