Zoom Map
To disable map zooming by mouse wheel or trackpad when initializing the map:
To toggle scroll zooming by button:
Sample web page:
To disable map zooming by mouse wheel or trackpad when initializing the map:
const maplibreMap = new maplibregl.Map({
container: 'map',
zoom: 17,
scrollZoom: false
});To toggle scroll zooming by button:
const disable = "Map scaling disable";
const enable = "Map scaling enable";
document.querySelector("#button").onclick = function(e) {
if (e.target.innerText === disable) {
maplibreMap.scrollZoom.enable();
e.target.innerText = enable;
return;
}
maplibreMap.scrollZoom.disable();
e.target.innerText = disable;
};Sample web page:

