[OpenLayers-Dev] restrictedExtent & maxExtent bug with OpenLayers &
	OpenStreetMaps
    japhy at xelentmapping.com 
    japhy at xelentmapping.com
       
    Mon Jan 26 10:29:51 EST 2009
    
    
  
I have encountered an apparent bug with restrictedExtent and maxExtent  
that only occurs (as far as I can tell) when I'm using a tiling system  
with another projection.
The first example code works fine, by which I mean I can NOT zoom out  
past the restricted area and I can NOT pan outside the restricted area:
   var bounds = new OpenLayers.Bounds(-75.8, 39.5, -74.2, 40.5);
   var map = new OpenLayers.Map(mapname, {
     restrictedExtent: bounds,
     maxExtent: bounds,
     maxResolution: "auto",
   });
   map.addLayer(
     new OpenLayers.Layer.WMS(
       "OL WMS",
       "http://labs.metacarta.com/wms/vmap0?",
       {layers: 'basic'}
     )
   );
   map.zoomToMaxExtent();
The second example code, using OSM's "mapnik" tiler, only prevents me  
from panning outside the restricted area.  It does not prevent me from  
zooming out to see the whole world:
   var EPSG4326 = new OpenLayers.Projection("EPSG:4326");
   var EPSG900913 = new OpenLayers.Projection("EPSG:900913");
   var bounds = new OpenLayers.Bounds(-75.8, 39.5, -74.2, 40.5);
   var map = new OpenLayers.Map(mapname, {
     displayProjection: EPSG4326,
     restrictedExtent: bounds.clone().transform(EPSG4326, EPSG900913),
     maxExtent: bounds.clone().transform(EPSG4326, EPSG900913),
     maxResolution: "auto",
   });
   map.addLayer(
     new OpenLayers.Layer.OSM.Mapnik("Mapnik", {
       displayOutsideMaxExtent: false,
       wrapDateLine: true,
     })
   );
   map.zoomToMaxExtent();
I asked the OSM list about this, but they said it didn't appear to be  
a problem on their end, and that I should ask the OpenLayers list  
instead.
Am I doing something wrong?
    
    
More information about the Dev
mailing list