4

How can I make leaflet zoom less with mouse wheel ? If I move my mouse wheel as little as I can, it zooms like 3 levels.

1

2 Answers 2

1

wheelPxPerZoomLevel: 150 is the option that it seems to be affecting the mouse wheel zoom "speed".

// @option wheelPxPerZoomLevel: Number = 50
// How many scroll pixels (as reported by [L.DomEvent.getWheelDelta](#domevent-getwheeldelta))
// mean a change of one full zoom level. Smaller values will make wheel-zooming
// faster (and vice versa).
wheelPxPerZoomLevel: 50
1
0

There appears to be an option that is not directly listed on the website documentation but the source has JsDoc lines for it...


this.options.zoomDelta is where you want to set the amount the zoom is changed by. this is your current Map object.

https://github.com/Leaflet/Leaflet/blob/6e8ac319931da744810bef81fffbfc4adbf3a39a/src/map/Map.js#L94 https://github.com/Leaflet/Leaflet/blob/6e8ac319931da744810bef81fffbfc4adbf3a39a/src/map/Map.js#L160


For mouse-wheel zooming, or pinch zooming. Adjusting this.options.zoomSnap setting will make it snap or settle on levels.

https://github.com/Leaflet/Leaflet/blob/a069c41dd7b1f6a58a47dab26be863c107d18a9f/src/map/Map.js#L95


Looking at the zoom controls, currently holding Shift and clicking the control zooms in by three times the current value of map.options.zoomDelta. This does not seem to be true of the mouse operation.

https://github.com/Leaflet/Leaflet/blob/a069c41dd7b1f6a58a47dab26be863c107d18a9f/src/control/Control.Zoom.js#L66

4
  • Those variables seem to only affect the zoom in/out buttons, not the mouse wheel. Just checked it.
    – dimitris93
    Commented May 16, 2016 at 21:12
  • I found the answer, I am posting an answer. wheelPxPerZoomLevel is what I need to change.
    – dimitris93
    Commented May 16, 2016 at 21:14
  • Sorry about that I read over the mouse wheel part. Sorry on that!
    – RomaH
    Commented May 16, 2016 at 21:15
  • Well, you helped me look in the right place :D
    – dimitris93
    Commented May 16, 2016 at 21:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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