首页 / MapLibre / 使用示例
禁用地图旋转
只允许平移和缩放,右键拖拽、双指旋转、键盘旋转全部关闭,视角始终朝北。
源码与运行效果
说明
构造时 dragRotate 与 pitchWithRotate 关掉,touchPitch 也关掉,再单独调用 touchZoomRotate.disableRotation() 覆盖触屏路径。
键盘旋转要单独 disableRotation(),构造参数管不到它。
| 配置 | 取值 | 说明 |
|---|---|---|
dragRotate | false | 关掉鼠标右键旋转 |
pitchWithRotate | false | 关掉随旋转改俯仰 |
touchZoomRotate.disableRotation() | 方法 | 关掉双指旋转 |
只关 dragRotate 时,触屏双指仍能旋转,必须补上 touchZoomRotate.disableRotation()。