MapBox - 如何禁用 mapbox-gl-js 中除旋转和缩放到设定点之外的所有移动

问题描述 投票:0回答:1

我正在尝试禁用地图的所有移动,除了旋转和缩放到设定点之外。 但在触摸设备上,我仍然可以用两根手指将“相机”从设定点移动,它在非触摸设备上工作正常。

这是我目前所拥有的,但并不能完全工作,我仍然可以用两根手指在触摸设备上移动相机中心点。我正在使用带有离子/角度的打字稿。

this.map = new mapboxgl.Map({
      container: 'game_map',
      style: 'mapbox://styles/mapbox/light-v10',
      center: [coords],
      zoom: 20,
      touchZoomRotate: {around: 'center'},
      scrollZoom: {around: 'center'},
      pitch: 60,
      bearing: -60,
      antialias: true,
      attributionControl: false,
      maxZoom: 22,
      minZoom: 17
    });
javascript typescript mapbox mapbox-gl-js
1个回答
4
投票

您可以通过添加以下内容来禁用用户平移:

 dragPan: false,

到该初始化语句。 更多信息

© www.soinside.com 2019 - 2024. All rights reserved.