Eli*_*rig 5 javascript mapbox mapbox-gl-js
Mapbox:无法禁用触摸设备上的 3D 倾斜
我尝试使用以下功能禁用倾斜但没有成功:
map.current.dragPan.disable(); map.current.dragRotate.disable(); map.current.touchZoomRotate.disable();
小智 2
我用它来将音调固定为自上而下,从而禁用任何手势。
map.setMaxPitch(0);
map.setMinPitch(0);
Run Code Online (Sandbox Code Playgroud)
第二个版本(参见https://docs.mapbox.com/mapbox-gl-js/api/map/#map#touchpitch):
// disable map tilting using two-finger gesture
map.touchPitch.disable();
Run Code Online (Sandbox Code Playgroud)
您尝试的其中两件事实际上禁用了地图的旋转,因为北方不再“向上”。
// disable map rotation using right click + drag
map.dragRotate.disable();
// disable map rotation using touch rotation gesture
map.touchZoomRotate.disableRotation();
Run Code Online (Sandbox Code Playgroud)
此处还进行了解释: https ://docs.mapbox.com/mapbox-gl-js/example/disable-rotation/