[OpenLayers-Dev] How to dynamically set maxExtent and
mpriour at kestrelcomputer.com
Thu May 26 11:25:30 EDT 2011
First, this question is suited to the user's list not the developer's list. The developer's list is for questions or discussions about developments in the actual OpenLayers library, not using OpenLayers for development.
You can just set the restricted extent directly on the layers of interest once the selection is made
Thirdly if you want to precisely control things yourself you can listen to and react to the map's 'movestart' & 'moveend' events. and also the 'move' event if you want finer control.
Cache the location when movestart fires
Test the current location (extent, zoom, etc) as move or moveend fires
If using move event, then if the location is within the limit then change the cached location to the current location
When moveend fires, if the map is outside of the acceptable bounds for the area you are focusing on, then move it back to the cached location programattically (ie map.setCenter(....) )
Kestrel Computer Consulting
From: openlayers-dev-request at lists.osgeo.org
Sent: Thursday, May 26, 2011 11:00 AM
To: openlayers-dev at lists.osgeo.org
Subject: Dev Digest, Vol 56, Issue 28
Send Dev mailing list submissions to
openlayers-dev at lists.osgeo.org
To subscribe or unsubscribe via the World Wide Web, visit
or, via email, send a message with subject or body 'help' to
openlayers-dev-request at lists.osgeo.org
You can reach the person managing the list at
openlayers-dev-owner at lists.osgeo.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Dev digest..."
Date: Wed, 25 May 2011 09:04:55 -0700
From: "Mark K. Zanfardino" <mzanfardino at gmail.com>
Subject: [OpenLayers-Dev] How to dynamically set maxExtent and
To: OpenLayers-Dev Dev <dev at openlayers.org>
Message-ID: <4DDD28A7.9080504 at gmail.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
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
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.
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
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Dev