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

In the ArcGIS Server JavaScript API 2.4, there are some related methods for getting and setting the map's extent.

  • map.getLevel() determine's the map's current level (when using a Tiled layer)
  • map.setExtent(extent) changes the map's extent to the new extent
  • map.setLevel(level) changes the map's level to the new level

Is it possible to determine what level the value of extent would equate to, before changing to that extent? That is, before I pass in map.setExtent(x1, y1, x2, y2) I want to know what level this would display, so that I can adjust the value as necessary.

I can set a listener on map.onExtentChange, verify the new level, and use map.setLevel(map.getLevel() + 1) to fix the extent if necessary - but this means the map may draw twice (once after map.setExtent then again after map.setLevel)

As far as I can see, there is no equivalent of extent.getLevel - is there a way to calculate this without actually changing the map level first?

share|improve this question
I'm still interested in finding an answer to this question. As a workaround, I'm using a larger value of extent.expand to increase the margin around my address point for certain layers – Stephen Lead Jul 14 '11 at 5:22

You can call the internal _fixExtent method on the map object to get the new LOD. Main caveat is that it is an internal method, so it may or may not change in the future. If you're concerned about it changing in the future though, you could always look at its code and replicate it to your own liking.


var fixed = map._fixExtent(extent, fit);
var level = fixed.lod.level;
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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