set zoom level one more than a given extent

1996
1
03-04-2014 11:57 AM
JorgeFiallega
New Contributor
Currently I have a handle on a polygon and I set the extent of the map by doing
map.setExtent(polygon.getExtent(), true);

I would like to be able to move out one more level from the given extent. Meaning from the result of the setExtent operation above.

I guess I could pseudocode  so something like

1. map.setExtent(polygon.getExtent(), true);
2. extentDoneCallBack(map.setLevel(map.getLevel() + 1));


making use of the deferred call back of the setExtent action.

Would this be the correct approach. It does not look right to me.
0 Kudos
1 Reply
JorgeFiallega
New Contributor
So the couple of lines of code look like this

        map.setExtent(polygon.getExtent(), true).then(function(){
          map.setLevel(map.getLevel() - 1)
        } );


The problem that I have is that visually so see it zooming in and then zooming out one level.
What I need is to calculate what level the extent would be , and only then set the level on the map to level -1.

The question is if is there any way to know what level a polygon would be displayed, without setting anything on the map, and then just set the level - 1.
0 Kudos