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 objectZoom 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);
Compass
The compass indicates the map's orientation. It is hidden by default. To show it, call the following method:
setCompassEnabled(boolean b);
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
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() {}
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 positionNote:The logo is hidden by default. You can display it by calling the IAMap.setLogoEnable interface and setting it to true.