Document Maps SDK for Android Guides Controls and Gestures Controls

Controls

Controls are UI components that float on the map surface, enabling users to interact with the map. These include zoom buttons, a compass, a location button, a scale bar, and more.

The UiSettings class manages these controls, allowing you to customize the map's appearance and behavior. To instantiate a UiSettings object, use the AMap class:

private UiSettings mUiSettings; // Declare a UiSettings object
mUiSettings = aMap.getUiSettings(); // Instantiate the UiSettings object

Zoom Buttons

Zoom buttons allow users to control the map's zoom level. Each click changes the zoom level by one increment. This control is enabled by default. To hide it, call the following method:

setZoomControlsEnabled(boolean b);

Android Maps SDK map showing the zoom-in and zoom-out buttons positioned on the map

Name

Meaning

Rule Description

setZoomControlsEnabled(boolean)

Whether to show the zoom buttons

Pass false to hide the zoom buttons

setZoomPosition(int position)

Sets the position of the zoom buttons

Use one of the AMapOptions.ZOOM_POSITION_* constants

getZoomPosition()

Gets the current position of the zoom buttons

Returns an integer constant

Compass

The compass indicates the map's orientation. It is hidden by default. To show it, call the following method:

setCompassEnabled(boolean b);

Android Maps SDK map showing the compass control indicating north direction on the map

Location Button

Users can tap the location button to display a blue dot on the map, marking their current position. Unlike other controls, the location button's internal logic depends on the Android Location SDK.

aMap.setLocationSource(this); // Set the location data source listener via the aMap object
mUiSettings.setMyLocationButtonEnabled(true); // Show the default location button
aMap.setMyLocationEnabled(true); // Trigger location and display the current position

Android Maps SDK map with the default location button showing the user current position

Scale Bar

The scale bar displays the map's scale (maximum: 1:10m, minimum: 1:1000km). It is located at the bottom-right corner of the map. To control its visibility, call the following method:

setScaleControlsEnabled(boolean b); // Control whether the scale bar is displayed
/**
 * Sets the position of the scale control.
 *
 * @param position Position coordinates. Pass null to keep the default position.
 * @since V5.7.0
 */
public void setScaleControlsPosition(Point position) {}

/**
 * Enumeration for scale control units.
 *
 * @since V11.1.200
 */
public enum ScaleControlsUnit {
    METRIC,
    IMPERIAL
}

/**
 * Sets the unit used by the scale control.
 *
 * @param unit The unit type to use for the scale control.
 * @since V11.1.200
 */
public void setScaleControlsUnit(ScaleControlsUnit unit) {}

/**
 * Gets the current unit used by the scale control.
 *
 * @return The currently set scale control unit.
 * @since V11.1.200
 */
public ScaleControlsUnit getScaleControlsUnit() {}

Android Maps SDK map showing the scale bar control with distance measurement display

Map Logo

The AMAP logo is displayed by default in the bottom-left corner of the map. To set the logo position, call the following method:

setLogoPosition(int position); // Set the logo position

Note:The logo is hidden by default. You can display it by calling the IAMap.setLogoEnable interface and setting it to true.

Logo Position Constants

Name

Meaning

Rule Description

AMapOptions.LOGO_POSITION_BOTTOM_LEFT

Logo position (bottom-left corner)

Logo margin (left) is applied

AMapOptions.LOGO_MARGIN_BOTTOM

Logo margin (bottom)

Sets the bottom margin of the logo

AMapOptions.LOGO_MARGIN_RIGHT

Logo margin (right)

Sets the right margin of the logo

AMapOptions.LOGO_POSITION_BOTTOM_CENTER

Logo position (bottom-center)

Positions the logo at the bottom center of the map

AMapOptions.LOGO_POSITION_BOTTOM_RIGHT

Logo position (bottom-right corner)

Positions the logo at the bottom right of the map