[英]MapBox GL JS: Make a non-interactive map interactive
In my web application, initially the map is set to be non-interactive (the user can't move around the map):在我的 Web 应用程序中,最初将地图设置为非交互式(用户无法在地图上移动):
var map = new mapboxgl.Map({
container: 'map',
style: 'mapbox://styles/mapbox/dark-v10',
zoom: 11,
interactive: false
});
However, when the user clicks a button, I want the map to become interactive (the user can move around the map).但是,当用户单击按钮时,我希望地图变得可交互(用户可以在地图上移动)。 I've tried setting the interactive property to true, but it doesn't work:我试过将交互属性设置为 true,但它不起作用:
map.interactive = true;
Any suggestions?有什么建议?
You're correct in that you cannot change the interactive
option after you've instantiated your map instance.您是正确的,因为在实例化地图实例后无法更改interactive
选项。 So it seems you have a couple of options:所以看起来你有几个选择:
1) Instantiate a new, non interactive map and replace the interactive one. 1) 实例化一张新的非交互式地图并替换交互式地图。
2) Disable pointer-events
css rule on your map container element as mentioned in the issue tracker: https://github.com/mapbox/mapbox-gl-js/issues/7992 2)禁用问题跟踪器中提到的地图容器元素上的pointer-events
css规则: https : //github.com/mapbox/mapbox-gl-js/issues/7992
Good luck!祝你好运!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.