目录

Gesture Interaction

Use Cases

This section describes how to use map gestures.

Map Kit provides multiple gestures for users to interact with maps. For example, pinch with two fingers to zoom in or out on the map, drag with one finger to pan the map view, rotate with two fingers to change the map orientation, and slide up or down with two fingers to adjust the map view angle. These gestures are enabled by default. You can use APIs provided by the MapComponentController class to disable some of the gestures.

API Description

The following table lists the map gesture APIs. Gestures can be enabled or disabled in either of the following ways:

API Description
setZoomGesturesEnabled(enabled: boolean): void

Sets whether to enable zoom gestures.

The default value is true.

setScrollGesturesEnabled(enabled: boolean): void

Sets whether to enable scroll gestures.

The default value is true.

setRotateGesturesEnabled(enabled: boolean): void

Sets whether to enable rotation gestures.

The default value is true.

setTiltGesturesEnabled(enabled: boolean): void

Sets whether to enable tilt gestures.

The default value is true.

setAllGesturesEnabled(enabled: boolean): void

Sets whether to enable gestures.

The default value is true.

Development Procedure

Obtain a mapController object during map initialization. For details about the map initialization function, please refer to Displaying a Map.

[h2]Map Interaction Gestures

You can use a mapController object to enable or disable relevant map gestures.

Zoom gestures:

A user can pinch two fingers to zoom in or out on the map.

this.mapController.setZoomGesturesEnabled(true);

Scroll gestures:

A user can drag the map to move it.

this.mapController.setScrollGesturesEnabled(true);

Rotation gestures:

A user can rotate the map by placing two fingers on it and rotating.

this.mapController.setRotateGesturesEnabled(true);

Tilt gestures:

A user can tilt the map by sliding two fingers up and down on the map.

this.mapController.setTiltGesturesEnabled(true);

Enabling or disabling all gestures:

Call the setAllGesturesEnabled method to enable or disable all gestures.

// Disable all gestures.
this.mapController.setAllGesturesEnabled(false);