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?

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);

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);

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

and in onmapReady insert this :

mMap.getUiSettings().setRotateGesturesEnabled(false);


Need Your Help

Laravel 5 PDOException Could Not Find Driver

php mysql laravel laravel-5

I have a problem using Laravel 5. When I run "php aritsan migrate", I got this error

Efficient way of getting @@rowcount from a query using row_number

sql sql-server sql-server-2005

I have an expensive query using the row_number over() functionality in SQL Server 2005. I return only a sub list of those records as the query is paginated. However, I would like to also return the