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?

  • 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 Jul 14, 2011 at 5:22

1 Answer 1


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;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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