Class Info |
|---|
public class Marker Icon placed at the specified position on the map. An instance of this type will be returned when the addMarker method in the HuaweiMap class is called. |
Qualifier and Type | Method Name and Description |
|---|---|
float | getAlpha() Obtains the transparency of a marker. |
LatLng | Obtains the position of a marker. |
float | Obtains the rotation angle of a marker. |
String | Obtains the text snippet of a marker. |
Object | getTag() Obtains the tag attribute of a marker. |
String | getTitle() Obtains the title of a marker. |
float | Obtains the z-index of a marker. |
void | Hides the information window that is displayed for a marker. |
boolean | Checks whether a marker is clickable. |
boolean | Checks whether a marker can be clustered. |
boolean | Checks whether users can long press a marker to drag it. |
boolean | isFlat() Checks whether a marker is flatly attached to the map. |
boolean | Checks whether an information window is currently displayed for a marker. |
boolean | Checks whether a marker is visible. |
void | remove() Removes a marker from the map. |
void | setAlpha(float alpha) Sets the transparency of a marker. |
void | setAnchor(float anchorU, float anchorV) Sets the anchor point of a marker. CAUTION: This method has been deprecated. To set an anchor point, call setMarkerAnchor. |
void | setAnimation(Animation animation) Sets the animation of a marker. |
void | setClickable(boolean clickable) Sets whether a marker is clickable. |
void | setDraggable(boolean draggable) Sets whether users can long press a marker to drag it. |
void | setFlat(boolean flat) Sets whether a marker is flatly attached to the map. |
void | setIcon(BitmapDescriptor iconDescriptor) Sets the icon of a marker. |
void | setInfoWindowAnchor(float anchorU, float anchorV) Sets the anchor point of a marker's information window. The coordinate system used is the same as that of the anchor point of a marker. By default, the top-middle point of the marker image is used as the anchor point. |
void | setMarkerAnchor(float anchorU, float anchorV) Sets the anchor point of a marker. |
void | setPosition(LatLng latLng) Sets the position coordinates of a marker. |
void | setRotation(float rotation) Sets the rotation angle of a marker, that is, the angle in which the marker rotates around the anchor point clockwise. The rotation axis is perpendicular to the marker. |
void | setSnippet(String snippet) Sets the text snippet of a marker. If null is passed, no text snippet will be displayed. |
void | setTag(Object tag) Sets the tag attribute of a marker. If null is passed, the tag attribute will be cleared. |
void | setTitle(String title) Sets the title of a marker. By default, the title is empty. |
void | setVisible(boolean visible) Sets whether a marker is visible. |
void | setZIndex(float zIndex) Sets the z-index of a marker. |
void | Displays the information window for a marker. |
void | Starts the animation of a marker. |
Method |
|---|
public float getAlpha() Obtains the transparency of a marker. |
Returns
Type | Description |
|---|---|
float | Transparency of a marker. The value ranges from 0 to 1. |
Method |
|---|
public final LatLng getPosition() Obtains the position of a marker. |
Returns
Type | Description |
|---|---|
Marker position. |
Method |
|---|
public final float getRotation() Obtains the rotation angle of a marker. |
Returns
Type | Description |
|---|---|
float | Rotation angle of a marker. |
Method |
|---|
public final String getSnippet() Obtains the text snippet of a marker. |
Returns
Type | Description |
|---|---|
String | Text snippet of a marker. |
Method |
|---|
public Object getTag() Obtains the tag attribute (if it has been set) of a marker. |
Returns
Type | Description |
|---|---|
Object | Object if a tag has been set; null otherwise. |
Method |
|---|
public final String getTitle() Obtains the title of a marker. |
Returns
Type | Description |
|---|---|
String | Title string of a marker. |
Method |
|---|
public float getZIndex() Obtains the z-index of a marker. |
Returns
Type | Description |
|---|---|
float | Z-index, which indicates the overlapping order of a marker. |
Method |
|---|
public final void hideInfoWindow() Hides the information window that is displayed for a marker. This method is invalid for invisible markers. |
Method |
|---|
public boolean isClickable() Checks whether a marker is clickable. |
Returns
Type | Description |
|---|---|
boolean | true if a marker is clickable; false otherwise. |
Method |
|---|
public boolean isClusterable() Checks whether a marker can be clustered. |
Returns
Type | Description |
|---|---|
boolean | true if a marker can be clustered; false otherwise. |
Method |
|---|
public final boolean isDraggable() Checks whether users can long press a marker to drag it. |
Returns
Type | Description |
|---|---|
boolean | true if users can long press a marker to drag it; false otherwise. |
Method |
|---|
public final boolean isFlat() Checks whether a marker is flatly attached to the map. |
Returns
Type | Description |
|---|---|
boolean | true if a marker is flatly attached to the map; false otherwise. |
Method |
|---|
public final boolean isInfoWindowShown() Checks whether an information window is currently displayed for a marker. This method will not consider whether the information window is actually visible on the screen. |
Returns
Type | Description |
|---|---|
boolean | true if an information window is currently displayed for a marker; false otherwise. |
Method |
|---|
public final boolean isVisible() Checks whether a marker is visible. |
Returns
Type | Description |
|---|---|
boolean | true if a marker is visible; false otherwise. |
Method |
|---|
public final void setAlpha(float alpha) Sets the transparency of a marker. |
Parameters
Name | Description |
|---|---|
alpha | Transparency of a marker. The value ranges from 0 to 1.
The default value is 1. |
This method has been deprecated. To set an anchor point, call setMarkerAnchor.
Method |
|---|
public final void setAnchor(float anchorU, float anchorV) Sets the anchor point of a marker. Since of the values of U and V are fixed, this method always sets the anchor point to the bottom of the marker icon. |
Parameters
Name | Description |
|---|---|
anchorU | Horizontal coordinate of the anchor point of a marker. The value ranges from 0 to 1, expressed in a proportion of the marker image width. The default value is 0.5. |
anchorV | Vertical coordinate of the anchor point of a marker. The value ranges from 0 to 1, expressed in a proportion of the marker image height. The default value is 0.5. |
Method |
|---|
public void setAnimation(Animation animation) Sets the animation of a marker. |
Parameters
Name | Description |
|---|---|
animation | Animation. |
Method |
|---|
public void setClickable(boolean clickable) Sets whether a marker is clickable. |
Parameters
Name | Description |
|---|---|
clickable | Indicates whether a marker is clickable.
|
Method |
|---|
public final void setDraggable(boolean draggable) Sets whether users can long press a marker to drag it. |
Parameters
Name | Description |
|---|---|
draggable | Indicates whether users can long press a marker to drag it.
The default value is false. |
Method |
|---|
public final void setFlat(boolean flat) Sets whether to flatly attach a marker to the map. If the marker is flatly attached to the map, it will stay on the map when the camera rotates or tilts. Different from a ground overlay (GroundOverlay), the marker will remain the same size when the camera zooms in or out. If the marker faces the camera, it will always be drawn facing the camera and rotates or tilts with the camera. |
Parameters
Name | Description |
|---|---|
flat | Indicates whether to flatly attach a marker to the map.
The default value is false. |
Method |
|---|
public final void setIcon(BitmapDescriptor iconDescriptor) Sets the icon of a marker. If null is passed, the default marker will be used. |
Parameters
Name | Description |
|---|---|
iconDescriptor | Object containing an icon. |
Method |
|---|
public final void setInfoWindowAnchor(float anchorU, float anchorV) Sets the anchor point of a marker's information window. The coordinate system used is the same as that of the anchor point of a marker. By default, the top-middle point of the marker image is used as the anchor point. For details, please refer to setMarkerAnchor(float anchorU, float anchorV). |
Parameters
Name | Description |
|---|---|
anchorU | Horizontal coordinate of the anchor point of an information window. The recommended value ranges from 0 to 1, expressed in a proportion of the information window width. |
anchorV | Vertical coordinate of the anchor point of an information window. The recommended value ranges from 0 to 1, expressed in a proportion of the information window height. |
Method |
|---|
public final void setMarkerAnchor(float anchorU, float anchorV) Sets the anchor point of a marker. The anchor point is used to anchor a marker image to the map. The coordinates (0, 0), (1, 0), (0, 1), and (1, 1) respectively indicate the top-left, top-right, bottom-left, and bottom-right corners of the marker image. The following figure shows a marker's anchor point X whose coordinates are (0.5, 0.3).
|
Parameters
Name | Description |
|---|---|
anchorU | Horizontal coordinate of the anchor point of a marker. The recommended value ranges from 0 to 1, expressed in a proportion of the marker image width. The default value is 0.5. |
anchorV | Vertical coordinate of the anchor point of a marker. The recommended value ranges from 0 to 1, expressed in a proportion of the marker image height. The default value is 1. |
Method |
|---|
public final void setPosition(LatLng latLng) Sets the position coordinates of a marker. |
Parameters
Name | Description |
|---|---|
latLng | Position coordinates of a marker. |
Throws
Name | Description |
|---|---|
IllegalArgumentException | If the passed latlng is empty. |
Method |
|---|
public final void setRotation(float rotation) Sets the rotation angle of a marker, that is, the angle in which the marker rotates around the anchor point clockwise. The rotation axis is perpendicular to the marker. By default, the marker is north aligned, and the rotation angle is 0 degrees. |
Parameters
Name | Description |
|---|---|
rotation | Rotation angle of a marker. The default value is 0. |
Method |
|---|
public final void setSnippet(String snippet) Sets the text snippet of a marker. If null is passed, no text snippet will be displayed. |
Parameters
Name | Description |
|---|---|
snippet | Text snippet of a marker. |
Method |
|---|
public final void setTag(Object tag) Sets the tag attribute of a marker. The tag attribute can be any object. If null is passed, the tag attribute will be cleared. If you no longer use the tag attribute, call setTag(null) to clear it to prevent memory leakage from occurring on the app. |
Parameters
Name | Description |
|---|---|
tag | Tag of a marker. |
Method |
|---|
public final void setTitle(String title) Sets the title of a marker. By default, the title is empty. |
Parameters
Name | Description |
|---|---|
title | Title string. If this parameter is set to null, the existing title will be cleared. |
Method |
|---|
public final void setVisible(boolean visible) Sets whether a marker is visible. |
Parameters
Name | Description |
|---|---|
visible | Indicates whether a marker is visible.
The default value is true. |
Method |
|---|
public final void setZIndex(float zIndex) Sets the z-index of a marker. The z-index indicates the overlapping order of a marker. A marker with a larger z-index overlaps that with a smaller z-index. Markers with the same z-index overlap each other by the order in which they are added. |
Parameters
Name | Description |
|---|---|
zIndex | Z-index, which indicates the overlapping order of a marker. By default, the z-index is 0. CAUTION: If a marker is tapped, the marker will be place at the top and its z-index will be set to 3.4028235E38. |