Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I would like to get the min lat, min long, max lat, max long of my viewport in ArcGIS JS API. Is this possible?

share|improve this question

marked as duplicate by Derek Swingley, PolyGeo, Devdatta Tengshe, Fezter, iant May 22 '13 at 9:33

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Have you looked at the Map.extent property? it will give the extent in the map units. If the map is not in wgs84, you'll have to project those values to lat-long. – Devdatta Tengshe May 16 '13 at 8:29
Will this extent adjust dynamically once I start zooming? – parseFloat May 16 '13 at 8:38
Yes, the extent property gives the current extent of the map. – Devdatta Tengshe May 16 '13 at 8:56
This is likely a duplicate of Once one of these questions gets an accepted answer, the other should be closed. – Derek Swingley May 21 '13 at 15:54

We can use the map's extent property, to get the extent. Usually your map will be in webmercator. we'll have to project the bounds back to EPSG:4326 in that case.

You can use the following code:

//asuming your map is in web mercator

//get the bounds of the current view
var bnds=map.extent;

//project the bounds from webmercator to latlong
var bnds_latlong=esri.geometry.webMercatorToGeographic(bnds);
share|improve this answer
In my code I have the following requires: dojo.require(""); dojo.require("esri.geometry.extent"); dojo.require("esri.tasks.geometry"); Then I initialize the map and check map.extent. I'm getting a dojo loader error, however: Error {src: "dojoLoader", info: Object} – parseFloat May 16 '13 at 8:39
map = new esri.Map("map", {logo:false}); map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer("…)); console.log(map.extent); console.log(map.extent.xmax); // Am just getting 'undefined' for all this map.extent business – parseFloat May 16 '13 at 8:45
You map needs to be loaded, before you can query it for the extent. if you query it directly after adding the layer, without waiting for the map load, you will get errors. – Devdatta Tengshe May 16 '13 at 8:58
nevermind got it working--had to use dojo.connect(map, "onExtentChange", showExtent); – parseFloat May 16 '13 at 9:03

The simplest way to do this, if your map is in web mercator, is to use map.geographicExtent.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.