Disable scroll zoom
Prevent scroll from zooming a map.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Disable scroll zoom</title>
<meta property="og:description" content="Prevent scroll from zooming a map." />
<meta charset='utf-8'>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel='stylesheet' href='https://unpkg.com/maplibre-gl@5.9.0/dist/maplibre-gl.css' />
<script src='https://unpkg.com/maplibre-gl@5.9.0/dist/maplibre-gl.js'></script>
<style>
body { margin: 0; padding: 0; }
html, body, #map { height: 100%; }
</style>
</head>
<body>
<div id="map"></div>
<script>
const map = new maplibregl.Map({
container: 'map', // container id
style: 'https://demotiles.maplibre.org/style.json', // style URL
center: [-122.65, 45.52], // starting position
zoom: 3 // starting zoom
});
// disable map zoom when using scroll
map.scrollZoom.disable();
</script>
</body>
</html>