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

  • 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. May 16, 2013 at 8:29
  • Will this extent adjust dynamically once I start zooming?
    – parseFloat
    May 16, 2013 at 8:38
  • Yes, the extent property gives the current extent of the map. May 16, 2013 at 8:56
  • This is likely a duplicate of gis.stackexchange.com/q/61326/124 Once one of these questions gets an accepted answer, the other should be closed. May 21, 2013 at 15:54

2 Answers 2


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);
  • In my code I have the following requires: dojo.require("esri.map"); 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, 2013 at 8:39
  • map = new esri.Map("map", {logo:false}); map.addLayer(new esri.layers.ArcGISTiledMapServiceLayer("geodata.npolar.no/ArcGIS/rest/services/inspire1/…)); console.log(map.extent); console.log(map.extent.xmax); // Am just getting 'undefined' for all this map.extent business
    – parseFloat
    May 16, 2013 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. May 16, 2013 at 8:58
  • nevermind got it working--had to use dojo.connect(map, "onExtentChange", showExtent);
    – parseFloat
    May 16, 2013 at 9:03

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

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