Select to view content in your preferred language

setting map.extent puts viewer at highest zoom level

1070
6
11-10-2010 04:21 AM
JamesHolstead
Emerging Contributor
(SFV 1.3, sri 102xxx)

Passing in extents from the database and using the following code to set the map extent. Whenever one of the extents are set, the viewer zooms in all the way.

var ext:String = event.data.toString();
    var extArray:Array = ext.split(" ");
    var extent:Extent = new Extent(Number(extArray[0]), Number(extArray[1]), Number(extArray[2]), Number(extArray[3]));
    map.extent = extent;


Sometimes the extent works, most of the time it is at the highest zoom level. What calculation is failing and where I can help correct it?
Tags (2)
0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Emeritus
James,

   If you are using any cached/tiled map services than the maps extent is constrained to those LODs and the map will automatically jump to the LOD that is closest to the extent that you are attempting to set it to. Not sure if that is your issue or not. The other thing is make sure that you are passing in an extent that is in the same WKID as the map is.
0 Kudos
JamesHolstead
Emerging Contributor
Thanks for the response,

The extents may be gathered in 102000 and the first basemap is 102100, not sure if this matters. I will double check with my POC what they used to get the extents.

Most of the extents are fairly high in zoom level, but should not be anywhere near 100% zoomed in, they should be ~ level 10 out of 15+. Also the initial extent should view CONUS, but ends up zoomed in all the way somewhere in Kanas. This tells me it is not using the closest LOD 😞
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
James,


   You should not be attempting to set the maps extent using coordinates that are not the same as the maps coordinate system. That is likely your issue.
0 Kudos
JamesHolstead
Emerging Contributor
As an experiment, using the ESRI World_Map 102100 and the Coordinate Banner mod, I zoomed out and collected an extent using the coordinates displayed on the banner. Not sure if this loses precision from the map.toMapFromStage() function. The result was the same, map zoomed in 100%.

The extent:
-7857063.7853 5126174.3537 -7845626.8949 5119715.4248

I searched the entire project for any map.zoomIn() calls or map.extents that may be called out of place but found nothing.
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
James,

   Actually no that I think about this I am pretty far off base with my comment
You should not be attempting to set the maps extent using coordinates that are not the same as the maps coordinate system

You absolutely can do this as long as you specify what this new extents WKID is

var extent:Extent = new Extent(Number(extArray[0]), Number(extArray[1]), Number(extArray[2]), Number(extArray[3]),new SpatialReference(102000));
0 Kudos
JamesHolstead
Emerging Contributor
Just had my Homer moment, DOH.

x,y points are backwards

The points were entered as: x2 y2 x1 y1 or vice versa. After reversing the points the extents work great. They were indeed collected using

Thanks again for your assistance!!!
0 Kudos