I'm using latest version of OpenLayers 6 and I noticed that even in the official examples there is small problem (or it is a feature) with mouse zoom. When I set zoom restrictions then while using the zoom in/zoom out buttons I can't zoom more or zoom out according those restrictions. But with mouse wheel it behaves strange, the map is zoomed out (despite restrictions) and when you stop it comes back to its place.

Take a look here: https://www.screencast.com/t/P6skAIhl433V

Is there a way to disable it?

  • To be able to zoom out so more than a world width is visible you need multiWorld: true set in the view options. See the documentation openlayers.org/en/latest/apidoc/module-ol_View-View.html – Mike Feb 29 '20 at 20:05
  • 1
    A would dare to call this a bug. I tested the code on an older version of ol6 (don't now exactly which, I think it's 6.1.1) and it does not behave this way. I can confirm this strange behaviour on version 6.2.1. – TomazicM Feb 29 '20 at 20:42
  • 1
    The overshoot and bounce back effect is due to the smoothExtentConstraint default. Set smoothExtentConstraint: false in the view options to disable it. – Mike Feb 29 '20 at 20:54
  • @Mike So this default value changed lately or is this new functionality? – TomazicM Feb 29 '20 at 21:01
  • @TomazicM It was new in 6.0.0 multiWorld only applies to global projections. Previously constraint options were set in the default interactions settings, not the view. – Mike Feb 29 '20 at 22:36

You can disable it using smoothResolutionConstraint: false set on the view.

Thanks @Mike for tip where to look for it!

  • 1
    Mike has not given just a tip, he gave you a complete answer. – TomazicM Feb 29 '20 at 21:14
  • @TomazicM No... He proposed smoothExtentConstraint which not work in my case. smoothResolutionConstraint did the work. Read carefully next time... – Dawid Rutkowski Feb 29 '20 at 21:16
  • Yes, smoothExtentConstraint would only apply when trying to pan outside a defined extent, not zooming out beyond it. – Mike Feb 29 '20 at 22:41
  • @DawidRutkowski Ups, sorry. It's a looong option name, beginning and end is the same, so ... I upvoted your answer now (if that counts :-). – TomazicM Mar 1 '20 at 10:20
  • @TomazicM I posted an answer so that others could find answer quicker. Personal;y I don't care about points:) – Dawid Rutkowski Mar 1 '20 at 19:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.