Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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

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.

Syntax:

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

Your Answer

 
discard

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.