How do I disable rotation in Mapbox Android SDK

Viewed 2990

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?

2 Answers

Solved with the following code! Thanks for the hint.

...
mapView.getMapAsync(new OnMapReadyCallback() {
    @Override
    public void onMapReady(MapboxMap mapboxMap) {
        mapboxMap.getUiSettings().setRotateGesturesEnabled(false);
    }
});
...
Related