Zooming to a extent.

701
2
Jump to solution
11-16-2012 11:34 PM
PrasannaRaghavendar
New Contributor III
Hi,

I have a map and the min longitude, min latitude, max longitude and max latitude values of a country.
Say the values are, -1.41382, 42.42873, 1.78659, 42.65601.
How should I zoom the map to this extent?

Thanks
Prasanna
0 Kudos
1 Solution

Accepted Solutions
PrasannaRaghavendar
New Contributor III
I found out that doing this would zoom 🙂

var mercExtent =new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,"spatialReference":{"wkid":4326}});// esri.geometry.geographicToWebMercator(geoCountryExtent) as esri.geometry.Extent;     var startExtent= esri.geometry.geographicToWebMercator(mercExtent);


So, the latitude and longitude values are the Geographic coordinates while the x, y coordinates are the WebMercator coordinates?

Thanks
Prasanna

View solution in original post

0 Kudos
2 Replies
PrasannaRaghavendar
New Contributor III
I found out that doing this would zoom 🙂

var mercExtent =new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,"spatialReference":{"wkid":4326}});// esri.geometry.geographicToWebMercator(geoCountryExtent) as esri.geometry.Extent;     var startExtent= esri.geometry.geographicToWebMercator(mercExtent);


So, the latitude and longitude values are the Geographic coordinates while the x, y coordinates are the WebMercator coordinates?

Thanks
Prasanna
0 Kudos
JanJeske
New Contributor III
Hey if the spatialReference  of your map is the same as of the extent  you can try this.

var mercExtent =new esri.geometry.Extent({"xmin":xmin,"ymin":ymin,"xmax":xmax,"ymax":ymax,"spatialReference":{"wkid":4326}});
map.setExtent(mercExtent );


Hope it helps you :).....

Here is a link to the API Reference

http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi_start.htm
0 Kudos