standard focus level

704
1
01-05-2012 07:13 AM
TonyRopson
New Contributor
 map.setExtent(esri.graphicsExtent(SearchPar[0].features).expand(5.2), true);


The application focuses on the area of the map the end user selected and than expands back out.  However the zoom level is not consistent if the area of the map is larger or smaller .  For instance if the end user wants to see all the adjacent areas within a mile for a piece of property zoom will show this if it is a large section but not if it is a smaller section.  So I am wondering if there is a way to make the focus consistent so the user can see the same things if the focus is on a large or small property.
0 Kudos
1 Reply
JeffPace
MVP Alum
 map.setExtent(esri.graphicsExtent(SearchPar[0].features).expand(5.2), true);


The application focuses on the area of the map the end user selected and than expands back out.  However the zoom level is not consistent if the area of the map is larger or smaller .  For instance if the end user wants to see all the adjacent areas within a mile for a piece of property zoom will show this if it is a large section but not if it is a smaller section.  So I am wondering if there is a way to make the focus consistent so the user can see the same things if the focus is on a large or small property.


First, are you using tiled or dynamic services.  If tiled, remember that you are snapping to a particular tile level and therefore can't go "exactly" 1 mile out. I will assume tiled since you are referring to levels.

If you always want to go out 1 mile, you shouldnt be using the expand command.  Expand using the current extent and a ratio.  Below expands a given extent a given distance

var expandFactor = /* half of whatever distance in map units */;

var newExtent = new esri.geometry.Extent({"xmin":map.extent.xmin-expandFactor,"ymin":ymin-expandFactor,"xmax":xmax+expandFactor,"ymax":ymax+expandFactor,
  "spatialReference":map.spatialReference});

map.setExtent(newExtent);

0 Kudos