'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 1:[1]
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);
Solution 2:[2]
Solved with the following code! Thanks for the hint.
...
mapView.getMapAsync(new OnMapReadyCallback() {
@Override
public void onMapReady(MapboxMap mapboxMap) {
mapboxMap.getUiSettings().setRotateGesturesEnabled(false);
}
});
...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | IntelliJ Amiya |
Solution 2 | Rickertbrandsen |