Select to view content in your preferred language

esri.Map.setExtent mutates extent?

635
2
07-20-2010 07:29 AM
__Rich_
Deactivated User
(AGS JS API 1.6)

I have an extent that I want to use as a default so at any point I can call map.setExtent(defaultExt) but it appears that setExtent is mutating the value of defaultExt.

If I check the min/max values before and after the call to setExtent they are changed, has anyone else seen this?

It means that I effectively end up with moving goalposts, I suppose I'll have to clone my default extent and pass the clone to setExtent.
0 Kudos
2 Replies
derekswingley1
Deactivated User
Yes, I've ran into this before. I *think* I reported it as a bug but I don't have a bug ID. I used the solution you're describing; always pass a copy of your extent to setExtent.
0 Kudos
jerrycox
New Contributor
Unfortunately it is a "feature" of ArcGIS to return an extent for an image that is not what was asked for in the request.  This "feature" is meant to preserve the aspect ratio, or some nonsense.  Try this one out.  Send an ExportMap request to ArcGIS Server where the extent is not rectangular in shape and the JSON response will have an extent that is entirely different from what you asked for.  Compare the coordinates of your initial extent with the extent reported in the JSON response.  You will probably see that what you asked for is not what you get unless your initial request contained an extent that was rectangular with a ratio of 3:4 or 9:16.

Take a look at http://resources.esri.com/help/9.3/arcgisserver/apis/rest/index.html.  Here is the real deal cut and paste from the help page.
                                                                                                                          
    "Note that the extent displayed in the exported map image may not exactly match the extent sent in the bbox parameter when the aspect ratio of the image size does not match the aspect ratio of the bbox.  The aspect ratio is the height divided by the width.  In these cases the extent is re-sized to prevent map images from appearing stretched.  The exported map�??s extent is sent along with the json and html responses and may be used in client side calculations.

     So it is important that the client-side code update its extent based on the response."

Yes, you'll have to manage the "moving goalposts"

Good Luck,

J. Cox
0 Kudos