Extent bounds not respected on zoom

285 views Asked by At

I came across a strange ol3 behaviour using the extent property of the ol.View to restrict the map navigation bounds.

To reproduce the error you should create a Map with a limited extent of the ol.View, like this..

var map = new ol.Map({
    layers: layers,
    target: 'map',
    view: new ol.View({
      center: [-10997148, 4569099],
      extent: [-13884991, 2870341, -7455066, 6338219]
    })
});

Here an example with a modified version of the "WMS custom tile grid 512x256" example on jsfiddle [ http://jsfiddle.net/dpynhg67/1/ ]

The extent is limited to the US, follow this steps to reproduce the bug:

  1. Zoom out to see also the europe
  2. Position the pointer somewhere in europe and zoom in with mouse wheel (you will be able to zoom outside the extent)
  3. As soon you try to pan, the view is moved to the extent configured in the View

Is this the wanted behaviour of the map? Do you have any suggestion on how to force the View to the extent?

Because as I remember OL2 behaved differently, while zooming the map was also panned to respect the extent.

1

There are 1 answers

0
ahocevar On BEST ANSWER

The issue you observed should be fixed now. The first release with the fix will be v3.21.0. The related ticket with links to the pull requests that fixed the bug is #5824.