Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable the map rotation feature in the Android Map Fragment

I use the Google Maps Api Version 2 for Androidto add a MapFragment to my Application.

This Fragments improves a lot in terms of speed and API usability. Sadly it also allows to rotate the map with a two finger gesture. I want to disable the rotation because this two finger gesture is often recognized instead of the gesture for zooming.

How can I disable the map rotation?

like image 814
Janusz Avatar asked Dec 04 '12 09:12

Janusz


People also ask

How do I stop Google Maps from rotating?

Open the Google Maps app. Tap on the menu key (3 horizontal bars) > Settings . Tap on Navigation settings . Clear the Tilt map checkbox.

How can we enable or disable the zoom in the map in Android Studio?

The Maps API provides built-in zoom controls that appear in the bottom right hand corner of the map. These are disabled by default, but can be enabled by calling UiSettings. setZoomControlsEnabled(true) .


1 Answers

It turned out to be straight forward if you look into the right place in documentation.

There is a UiSettings class inside a GoogleMap that allows enabling and disabling of gestures.

  SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.maps_fragment);   GoogleMap map = mapFragment.getMap();   map.getUiSettings().setRotateGesturesEnabled(false); 
like image 92
Janusz Avatar answered Oct 04 '22 01:10

Janusz