最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - MapBox - How to disable all movement in mapbox-gl-js except rotation and zoom to a set point - Stack Overflow

programmeradmin2浏览0评论

I 'am trying to disable all movement of the map, except rotation and zoom to a set point. But on a touch device I can still move the 'camera' from the set point with two fingers, it works fine on a non touch device.

This is what I currently have, and that is not fully working I can still move the camera center point with two fingers on a touch device. I 'am using typescript with ionic/angular.

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
    });

I 'am trying to disable all movement of the map, except rotation and zoom to a set point. But on a touch device I can still move the 'camera' from the set point with two fingers, it works fine on a non touch device.

This is what I currently have, and that is not fully working I can still move the camera center point with two fingers on a touch device. I 'am using typescript with ionic/angular.

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
    });
Share Improve this question asked Jan 17, 2020 at 18:27 DaantricalDaantrical 1242 silver badges11 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

You can disable user panning by adding:

 dragPan: false,

to that initialisation statement. More info.

发布评论

评论列表(0)

  1. 暂无评论