开发者

OpenLayers minimal zoom smaller than bounding box

I've got a problem with osm and openlayers. first of all, my map object

var w开发者_如何转开发gs84 = new OpenLayers.Projection("EPSG:4326");
var map = new OpenLayers.Map ('map',
    {
    projection: new OpenLayers.Projection("EPSG:900913"),
    displayProjection: wgs84,
    maxExtent: new OpenLayers.Bounds(-180,-20, 180, 90),
    controls: [
    new OpenLayers.Control.MousePosition(),
    new OpenLayers.Control.PanZoomBar(),
    ]
    }); 

as you can see, my bounding box ends at -20, so the antarctis should be displayed.

but i'm able to zoom out so that i can see the whole world, and the map is smaller than the map-div (which is 900 * 500).

Is there any solution to fix it? you shouldn't be able to get a smaller map than the bounding box allows.


Have you implemented the restrictedExtent parameter?

(from the documentation) restrictedExtent

{OpenLayers.Bounds} Limit map navigation to this extent where possible. If a non-null restrictedExtent is set, panning will be restricted to the given bounds. In addition, zooming to a resolution that displays more than the restricted extent will center the map on the restricted extent.

See an example here - This stops you panning beyond the bounds but does not restict the zoom levels. This seems to be a heavily reported missing feature that has not had many resolutions.

I believe this SO post has some workarounds for it thoughMin Max Zoom level in OpenLayers

Hope I have been some help.


Take a look at the sample I did at http://beta1234.com.sunflower.arvixe.com/maps/ (the server is a bit slow). It uses restrictedExtent and restricted zoom levels.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜