Select to view content in your preferred language

Constrained Extent

2151
2
07-21-2010 03:10 AM
__Rich_
Deactivated User
I've seen various methods where people have tried to prevent users from straying outside a defined extent but nothing really works properly.

Has anyone managed to achieve this without resorting to some sort of server-side masking? (although I suspect ultimately that's going to be the only way to properly prevent users from seeing data outside an extent)

I notice for Silverlight there's ConstrainExtentBehavior which appears to be designed for this purpose, is there any equivalent for the JS API?  (even if it means 'porting' the functionality into custom JS)
0 Kudos
2 Replies
derekswingley1
Deactivated User
0 Kudos
__Rich_
Deactivated User
Have you looked at this sample:  http://resources.esri.com/arcgisserver/apis/javascript/arcgis/index.cfm?fa=codeGalleryDetails&script...

Yep...

...and it's too easy to break it! (edit: that's a bit unfair I probably need to re-work it a bit and see if it can be adjusted to suit my app)

The problem is all tied in with the way that the API avoids stretching images i.e. the extent you set isn't necessarily what you'll get and you can end up in an infinite loop!

Even though you try to force the user back to the maximum extent the resultant extent is outside that so you try again, and again, and again.....

If I had the time I'd sit down and work out an algorithm to calculate the maximum extent possible given the aspect ratio of the map container, it should be possible, if the right tools are present in the API.

But this does seem like something that should be included in the API anyway, Silverlight's got it, but switching APIs is not an option for me.

EDIT: Seems the sample only works if you specify the LODS, if they're removed then it goes a bit haywire.  I didn't really want to work with LODS, I'd rather my user could zoom to whatever scale they want, within the max extent of course. I also need the top LOD to be dynamically calculated from the max extent and I suppose I could calculate a bunch of LODS to allow zooming in to be reasonably custom.

I should point out that none of my layers are tiled and most of them aren't supplied by AGS but from several OGC WMSs and that the map container is resizble by the user.
0 Kudos