简体   繁体   English

Mapbox GL JS禁用滚动缩放

[英]Mapbox GL JS disable scroll zoom

Unable to disable the default zooming on scroll functionality on Mapbox GL JS. 无法禁用Mapbox GL JS上的默认缩放滚动功能。 Nothing in the API documentation sheds light on this. API文档中没有任何内容可以阐明这一点。 Even missing the scroll event in their docs. 甚至错过了他们文档中的滚动事件。

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

Inspected the map object, saw the scrollZoom and tried to call the disable. 检查了地图对象,看到了scrollZoom并试图调用disable。 Great success! 巨大的成功!

map.scrollZoom.disable();

Or in another way: 或以另一种方式:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM