36

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?

Charles
  • 50,943
  • 13
  • 104
  • 142
Janusz
  • 187,060
  • 113
  • 301
  • 369

3 Answers3

100

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);
Janusz
  • 187,060
  • 113
  • 301
  • 369
  • 2
    You should accept your answer -- or delete the question, as it's even shown in the Demo-App how to turn all those features on and off... – Ridcully Jan 05 '13 at 20:22
  • I also tried to find disabling zoom buttons and I found it in getUiSettings().setZoomControlsEnabled(false) – Amt87 Mar 03 '14 at 12:42
0

If you are creating your Google Map with code like this:

GoogleMapOptions googleMapOptions = new GoogleMapOptions();
...
mapFragment = SupportMapFragment.newInstance(googleMapOptions);

Then you can also disable the rotation gesture like this:

GoogleMapOptions googleMapOptions = new GoogleMapOptions();
...
googleMapOptions.rotateGesturesEnabled(false);
mapFragment = SupportMapFragment.newInstance(googleMapOptions);
ban-geoengineering
  • 18,324
  • 27
  • 171
  • 253
0

SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map); mapFragment.getMapAsync(this);

and in onmapReady insert this :

mMap.getUiSettings().setRotateGesturesEnabled(false);

mahsa k
  • 555
  • 6
  • 9