简体   繁体   中英

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

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

You can disable user panning by adding:

 dragPan: false,

to that initialisation statement. More info .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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