how to find the xmin ymin xmax ymax

16624
11
04-24-2011 10:45 PM
Sophialim
New Contributor
hi
i am using the
var startExtent = new esri.geometry.Extent(xmin, ymin, xmax, ymax, new esri.SpatialReference({ wkid: 4326 }));
            omap.map.setExtent(startExtent);
But how to find the xmin, ymin, xmax and ymax
the spatial reference 4326 need to change?
0 Kudos
11 Replies
PeterKobylarz
New Contributor
Can you explain why you are trying to get pre-defined x/y values? Are you trying to get the x/y values of the extent when the map resource loads? Or are you trying to get the coordinates for some other location?

Generally, when you add a layer (ArcGISTiledMapServiceLayer, ArcGISDynamicMapServiceLayer, etc) to your map object, the map's extent object automatically inherits the extent defined in your Map Service Layer. You can get the x/y values from this object by querying the map.extent x/y attributes (http://help.arcgis.com/EN/webapi/javascript/arcgis/help/jsapi_start.htm extent is under the geometry category on the right hand side).

You can also create an extent object and set its x/y values to the extent of another geometry object, such as a polygon.

In general, you shouldn't have to change the spatial reference unless you are dealing with data in mulitple spatial references.
0 Kudos
MatthewLawton
Occasional Contributor
You can define the xmin, ymin, xmax, ymax directly if you want to zoom to a specific location different than your default extent. 4326 appears to be the projection id for WGS 84, so I'm assuming it uses decimal degrees for the units. If you wanted to zoom to Los Angeles by default you could declare it like this:

var startExtent = new esri.geometry.Extent(-119.5, 32.5, -116.5, 35.5, new esri.SpatialReference({ wkid: 4326 }));
0 Kudos
melissaGomez
New Contributor III
I see this has been a long time since posted, but I was hoping to see the answer in how to exactly find those coordinates as the example shows for finding Los Angles? I need a refresher on how those coordinates were found. I do not have access to google earth and I know that would be a good source in finding these coordinates. Would anything else help? Please let me know. Thanks.
0 Kudos
AnthonyGiles
Frequent Contributor
Melissa,

This extent finder application for flex displays a lat/long read out that you can use to gather the coords you need,

http://help.arcgis.com/en/webapps/flexviewer/extenthelper/flexviewer_extenthelper.html

Its a shame that the extent is only shown in web mercator and not geographics

Regards

Anthony
melissaGomez
New Contributor III
This is perfect!! Thank you so much!!
0 Kudos
AnthonyGiles
Frequent Contributor
Melissa,

Please do not forget to mark the post as answered by doing the following on the post that best answered your question:

[ATTACH=CONFIG]19078[/ATTACH]

Regards

Anthony
0 Kudos
JohnGravois
Frequent Contributor
our st. louis regional office put together a sample application for helping streamline the task of identifying extents in both web mercator and wgs84 as well.
0 Kudos
JimBuehler
New Contributor
Thanks, Anthony!  That was excellent!

Equally impressive John!
0 Kudos
JohnGravois
Frequent Contributor
new map constructor options in version 3.3 of our API have simplified the process of controlling the initial extent of the map.

i put together a simple app to display map center and zoom level to try and make the process even easier.
0 Kudos