No, the problem that lies in this map is the scroll levels of one's own mouse settings. When I scroll I go from all out to all in. This is easily fixed by disabling scroll zoom ( window.map.scrollWheelZoom.disable()/scrollWheelZoom: false ) and employing a window.map.zoomIn(1) on a mouse wheel's scroll one way, and window.map.zoomOut(1) for the other.
The two ways to do this are to use getWheelDelta( <DOMEvent> e ) from L.DomEvent or use the native JS listening process. Using the latter was simple to set up. Just create a function to do the zooming.
function zoomFine(e) { var evt=window.event || e; //equalise event object var delta=evt.detail? evt.detail*(-120) : evt.wheelDelta; //delta returns +120 when wheel is scrolled up, -120 when scrolled down zoomindex=(delta<=-120)? window.map.zoomOut(1): window.map.zoomIn(1);
if (evt.preventDefault) { //disable default wheel action of scrolling page evt.preventDefault(); } else { return false; } }
and set up your listeners in your map initialiser:
var mouseWheelEvt=(/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel"; //FF doesn't recognize mousewheel as of FF3.x
var mapDiv=document.getElementById("map"); if (mapDiv.attachEvent) { //if IE (and Opera depending on user setting) mapDiv.attachEvent("on"+mouseWheelEvt, zoomFine); } else if (mapDiv.addEventListener) { //WC3 browsers mapDiv.addEventListener(mouseWheelEvt, zoomFine, false); }
Do not forget your default scroll wheel zoom disabler in window.map.scrollWheelZoom.disable() or with scrollWheelZoom: false in the map options.
No, the problem that lies in this map is the scroll levels of one's own mouse settings. When I scroll I go from all out to all in. This is easily fixed by disabling scroll zoom ( window.map.scrollWheelZoom.disable()/scrollWheelZoom: false ) and employing a window.map.zoomIn(1) on a mouse wheel's scroll one way, and window.map.zoomOut(1) for the other.
The two ways to do this are to use getWheelDelta( <DOMEvent> e ) from L.DomEvent or use the native JS listening process. Using the latter was simple to set up. Just create a function to do the zooming.
function zoomFine(e) {
var evt=window.event || e; //equalise event object
var delta=evt.detail? evt.detail*(-120) : evt.wheelDelta; //delta returns +120 when wheel is scrolled up, -120 when scrolled down
zoomindex=(delta<=-120)? window.map.zoomOut(1): window.map.zoomIn(1);
if (evt.preventDefault) { //disable default wheel action of scrolling page
evt.preventDefault();
} else {
return false;
}
}
and set up your listeners in your map initialiser:
var mouseWheelEvt=(/Firefox/i.test(navigator.userAgent))? "DOMMouseScroll" : "mousewheel";
//FF doesn't recognize mousewheel as of FF3.x
var mapDiv=document.getElementById("map");
if (mapDiv.attachEvent) { //if IE (and Opera depending on user setting)
mapDiv.attachEvent("on"+mouseWheelEvt, zoomFine);
} else if (mapDiv.addEventListener) { //WC3 browsers
mapDiv.addEventListener(mouseWheelEvt, zoomFine, false);
}
Do not forget your default scroll wheel zoom disabler in window.map.scrollWheelZoom.disable() or with scrollWheelZoom: false in the map options.
There, the problem is practically solved :)…