Document Maps SDK for Android Guides Controls and Gestures Gestures

Gestures

The Map SDK provides a variety of gestures that allow users to interact with the map, including zoom, scroll, rotate, and tilt. These gestures are enabled by default. To disable specific gestures, use the methods provided by the UiSettings class.

Gesture Methods

The following table lists the methods used to enable or disable gestures:

Name

Method

Zoom

UiSettings.setZoomGesturesEnabled(boolean)

Scroll

UiSettings.setScrollGesturesEnabled(boolean)

Rotate

UiSettings.setRotateGesturesEnabled(boolean)

Tilt

UiSettings.setTiltGesturesEnabled(boolean)

All gestures

UiSettings.setAllGesturesEnabled(boolean)

The following table lists the methods used to check whether a gesture is enabled:

Name

Method

Zoom

UiSettings.isZoomGesturesEnabled()

Scroll

UiSettings.isScrollGesturesEnabled()

Rotate

UiSettings.isRotateGesturesEnabled()

Tilt

UiSettings.isTiltGesturesEnabled()

Zoom Gesture

The zoom gesture changes the map's zoom level. The map responds to the following gestures:

- Double-tap the map to increase the zoom level by 1 (zoom in).

- Pinch or stretch with two fingers.

You can enable or disable the zoom gesture. Disabling the zoom gesture does not affect the user's ability to use the zoom controls on the map.

The following code shows how to enable or disable the zoom gesture:

UiSettings.setZoomGesturesEnabled(boolean);

Scroll Gesture

You can drag the map with one finger to pan (scroll) or flick the map for an animated scroll effect. You can also enable or disable the scroll (pan) gesture.

The following code shows how to enable or disable the scroll gesture:

UiSettings.setScrollGesturesEnabled(boolean);

Rotate Gesture

You can rotate the 3D vector map by turning two fingers on the map. You can also disable the rotate gesture.

The following code shows how to enable or disable the rotate gesture:

UiSettings.setRotateGesturesEnabled(boolean);

Tilt Gesture

Users can place two fingers on the map and move them together up or down to increase or decrease the tilt angle. You can also disable the tilt gesture.

The following code shows how to enable or disable the tilt gesture:

UiSettings.setTiltGesturesEnabled(boolean);

Gesture Operations with a Specified Screen Center

When performing gesture operations on the map (except for the scroll gesture), you can specify a screen center point before executing the gesture.

To specify the screen center point, use the following method in the AMap class:

setPointToCenter(int x, int y);

Note: x and y are screen coordinates. The origin (0, 0) is the top-left corner of the screen.

To enable gesture operations using the specified center point:

aMap.getUiSettings().setGestureScaleByMapCenter(true);