[OpenLayers-Dev] How to dynamically set maxExtent and restrictedExtent

Mark K. Zanfardino mzanfardino at gmail.com
Wed May 25 12:04:55 EDT 2011


What I'm trying to do:
I'm rending a map for an entire county. I have a simply html select 
option of extents that I wish to use to set focus on the map. I need to 
restrict the user from being able to zoom 'out' (pull back and see the 
entire county) or slide 'away' (drag the map to another area) after an 
option has been selected.

I currently initialize the map to the county view when the page loads 
(see http://pastebin.com/jSmnHtwS for HTML). I have written a function 
which will zoom to a new extent based on the selection of the option 
list (see http://pastebin.com/WBX0rmxz for JavaScript). All this works 
fine, but I'm stuck with how I can restrict the user from zooming 'out' 
or slipping 'away' from the focused extent.

I'm looking for any suggestions on what might be the best approach to 
achieve my objective.

Thanks,

Mark Zanfardino

PS - My apologies if this shows up as a duplicate. I received a notice 
that the first email I sent was quarantined do to the attachment of the 
javascript)


More information about the Dev mailing list