Mapbox GL JS disable scroll zoom

时间:2015-12-10 01:29:29

标签: javascript mapbox

Unable to disable the default zooming on scroll functionality on Mapbox GL JS. Nothing in the API documentation sheds light on this. Even missing the scroll event in their docs.

var map = new mapboxgl.Map({
  container: 'map',
  style: 'mapbox://styles/mapbox/streets-v8',
  zoom: 15
});

2 个答案:

答案 0 :(得分:5)

Inspected the map object, saw the scrollZoom and tried to call the disable. Great success!

map.scrollZoom.disable();

答案 1 :(得分:2)

或以另一种方式:

var map = new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/streets-v8',
    zoom: 15,
    scrollZoom      : false,
    boxZoom         : false,
    doubleClickZoom : false
});