[OpenLayers-Users] limit map to maxExtent?

Christopher Schmidt crschmidt at metacarta.com
Fri Jul 20 09:13:37 EDT 2007


On Fri, Jul 20, 2007 at 02:48:53PM +0200, Bart van den Eijnden (OSGIS) wrote:
> Hi list,
> 
> is there a way to limit the map to its maxExtent? Right now I can pan
> outside of the maxExtent.
> 
> I tried adding a check to setCenter in Map.js:
> 
> ..
> var bounds = this.getExtent();
> if (!this.maxExtent.containsBounds(bounds))
> { 
>   return false;
> }

Sounds like you want (from http://trac.openlayers.org/ticket/340):

Interpretation: loose

Context: map browsing – a base layer's resolutions have precedence
over maxExtent, but maxExtent is respected where possible. If the
requested map extent falls outside maxExtent in any direction, the
returned extent is adjusted by the difference. If the requested map
extent is completely outside the maxExtent in any dimension, the
returned extent is centered on maxExtent. 

I will follow up on the dev list, and see what we need to do to make
this happen. I've punted on it for far too long, and it's time to stop.

Regards,
-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list