How to prevent the map from moving when a user zooms in with scrollwheel?

I would like the center to be preserved in any case.

var mymap = L.map('spotmap', {
   dragging: false
}).setView(spot_LatLng, 18);

var marker = L.marker(spot_LatLng).addTo(mymap);

Set scrollWheelZoom option to 'center' when defining map:

var mymap = L.map('spotmap', {
   dragging: false,
   scrollWheelZoom: 'center'
}).setView(spot_LatLng, 18);
  • In the doc : Whether the map can be zoomed by using the mouse wheel. If passed 'center', it will zoom to the center of the view regardless of where the mouse was. Thank you very much @TomazicM
    – rudak
    Apr 24 '19 at 20:26

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.