Select to view content in your preferred language

How to set the map scale ratio in arcgis server by javascript?

3940
2
09-05-2011 12:28 AM
MdAziz
by
New Contributor
Hi everyone

Really I need to know the code for " How to set the map scale ratio in arcgis server by javascript?" I became crazy for this :mad: I know how to set the map extent or zoom to specific feature. But not sure how to set the scale ratio, how much should i plus/minus the extent. For example what I need to show I have attached a demo file. Like before hope this time also some one will come out to help me.

Thanks in advance. 🙂
0 Kudos
2 Replies
AxelSchaefer
New Contributor II
Have you tried this:

function zoomToScale(scale){
    map.setExtent(esri.geometry.getExtentForScale(map, scale));
}


regards,
a.
0 Kudos
MdAziz
by
New Contributor
Thanks a lot Axxl, ur key word really helps me to get the solution.

 
  var currentScale = esri.geometry.getScale(map.extent,map.width,map.spatialReference.wkid); 
  var scaleRatio = userScale / currentScale;
   var newExtent = map.extent.expand(scaleRatio);
   map.setExtent(newExtent); 
 
0 Kudos