Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Maps Android MapView v2: disable zooming

Is there a way to disable the zooming (pinch and double tap) in the MapView but keep the scrolling?

This means setting clickable to false would not work.

I have also tried setting an onTouch listener in the activity but it will not trigger using:

mapView.setOnTouchListener(this);
like image 278
Klaasvaak Avatar asked Apr 08 '13 12:04

Klaasvaak


People also ask

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

How do you reset zoom on Google Maps?

You can change the zoom level of the map using simple steps. Step 1 Go to Add or Edit Map page . Step 2 Select 'Default zoom level' in the 'Map Information section'. Step 3 click save map and see the changes.

What is zoom level in Google map?

The Google Maps API provides map tiles at various zoom levels for map type imagery. Most roadmap imagery is available from zoom levels 0 to 18, for example. Satellite imagery varies more widely as this imagery is not generated, but directly photographed.


2 Answers

import com.google.android.gms.maps.GoogleMap;

public void onMapReady(GoogleMap map) {
...
map.getUiSettings().setZoomGesturesEnabled(false);

UiSettings Documentation

like image 117
laalto Avatar answered Oct 04 '22 21:10

laalto


You can assign those properties using the XML file:

   map:uiRotateGestures="true"
   map:uiScrollGestures="true"
   map:uiTiltGestures="true"
   map:uiZoomGestures="true"

So use:

   map:uiZoomGestures="false"

On the MapFragment object.

like image 26
Emil Adz Avatar answered Oct 04 '22 22:10

Emil Adz