androidmapbox

How do I disable rotation in Mapbox Android SDK


I want to disable rotation (bearing) in Mapbox Android SDK because it is currently too sensitive - when I pinched to zoom, the map also rotate.

I tried adding these attributes to the layout:

<com.mapbox.mapboxsdk.maps.MapView
    ...
    mapbox:mapbox_cameraBearing="0.0"
    mapbox:mapbox_uiCompass="false"
    ... >
</com.mapbox.mapboxsdk.maps.MapView>

But learnt later that they are used for setting the initial rotation and hiding the compass respectively.

How do I disable the rotation in Mapbox Android SDK?


Solution

  • public void setRotateGesturesEnabled(boolean rotateGesturesEnabled)

    Changes whether the user may rotate the map.

    This setting controls only user interactions with the map. If you set the value to false, you may still change the map location programmatically.

    getUiSettings().setRotateGesturesEnabled(false);