[OpenLayers-Users] Problems with setting maxExtent

Christopher Schmidt crschmidt at metacarta.com
Mon Mar 5 20:49:41 EST 2007


On Tue, Mar 06, 2007 at 12:12:49AM -0000, John Roberts wrote:
> Dear All
> 
> I hope you might be able to help.
> 
> I am have just started learning OpenLayers and I finding it a very
> interesting product.
> 
> However I am having problems setting a maxExtent. I create a map with the
> maxExtent defined as below (2500 x 2500 metres).
> I then try to set the map to open up at the maxExtent.

Replace maxResolution: 1.40 with: "maxResolution: 'auto'".

-- Chris

> However when I use:
> 
> 1. zoomToExtent(maxBounds) or zoomToMaxExtent(), the view is returned as as
> approx 1000 by 700 metres, positioned at what appears the centre of the
> maxExtent. The zoom bar is set to 17, so I am unable to zoom out any more.
> However I can pan to the rest of the extent.
> 
> 2. map.setCenter(new OpenLayers.LonLat(-3.75,51.56), 6);: the view is
> returned much zoomed in, and when I zoom out to the maximum extent using the
> zoom bar, I am returned to the original extent of 1000 by 700 metres!
> 
> I suspect that I am missing something simple, but I just cannot see it! Has
> anybody got any suggestions?
> 
> Thanking you in advance.
> 
> John
> Manchester, UK
> 
> P.S. I attach the relevant bits of the HTML file below
> 
> ----------------------------------------------------------------------------
> ----------------------------------------------
> /* bounding box of 2500 metres by 2500 metres */
> var maxBounds = new OpenLayers.Bounds(277750,185750,280250,188250);
> 
> 
> var map = new OpenLayers.Map('map',{maxExtent: maxBounds,maxResolution:
> 1.40, units: 'meters', projection: "EPSG:27700"});
> 
> /* here I create 6 layers based on GeoServer WMS which all have extents
> approx equal to the bounds above */
> 
> map.addLayers([mmAreaC,mmAreaBW,mmLine,mmITN,mmAdpnt,mmText]);
> 
> map.addControl(new OpenLayers.Control.OverviewMap());
> map.addControl(new OpenLayers.Control.PanZoomBar());
> map.addControl(new OpenLayers.Control.LayerSwitcher());
> map.addControl(new OpenLayers.Control.MousePosition());
> 
> map.zoomToMaxExtent();
> /* map.zoomToExtent(maxBounds); */
> /* map.setCenter(new OpenLayers.LonLat(-3.75,51.56), 6); */
> 
> 
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
> 

-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list