目录

public class Marker

Defines an icon placed at a specified position on a map.

Public Fields

None.

Constructor

None.

Public Method Summary

Return typeMethod name
booleanequals(Object other)
floatgetAlpha()
StringgetId()
LatLnggetPosition()
floatgetRotation()
StringgetSnippet()
ObjectgetTag()
StringgetTitle()
floatgetZIndex()
inthashCode()
voidhideInfoWindow()
booleanisClusterable()
booleanisDraggable()
booleanisFlat()
booleanisInfoWindowShown()
booleanisVisible()
voidremove()
voidsetAlpha(float alpha)
voidsetAnchor(float anchorU, float anchorV)
voidsetMarkerAnchor(float anchorU, float anchorV)
voidsetDraggable(boolean draggable)
voidsetFlat(boolean flat)
voidsetIcon(BitmapDescriptor iconDescriptor)
voidsetInfoWindowAnchor(float anchorU, float anchorV)
voidsetPosition(LatLng latLng)
voidsetRotation(float rotation)
voidsetSnippet(String snippet)
voidsetTag(Object tag)
voidsetTitle(String title)
voidsetVisible(boolean visible)
voidsetZIndex(float zIndex)
voidshowInfoWindow()

Public Methods

Method
public boolean equals(Object other)
Checks whether a Marker object equals another.


Parameters:

Parameter nameParameter desc
otherName of another Marker object.


Return:

Return typeParameter desc
booleanIf the Marker objects are equal, true is returned. Otherwise, false is returned.
Method
public float getAlpha()
Obtains the opacity of a marker.


Parameters:
None.
Return:

Return typeParameter desc
floatOpacity of a marker. The value ranges from 0 to 1.
Method
public final String getId()
Obtains the ID of a marker on a map. The ID will be unique among all markers on a map.


Parameters:
None.
Return:

Return typeParameter desc
StringID of a marker.
Method
public final LatLng getPosition()
Obtains the position of a marker.


Parameters:
None.
Return:

Return typeParameter desc
LatLngPosition of a marker.
Method
public final float getRotation()
Obtains the rotation angle of a marker.


Parameters:
None.
Return:

Return typeParameter desc
floatRotation angle of a marker.
Method
public final String getSnippet()
Obtains the text of a marker.


Parameters:
None.
Return:

Return typeParameter desc
StringText of a marker.
Method
public Object getTag()
Obtains the tag of a marker if the tag has been set.


Parameters:
None.
Return:

Return typeParameter desc
ObjectTag of a marker. If no tag has been set, null is returned.
Method
public final String getTitle()
Obtains the title of a marker.


Parameters:
None.
Return:

Return typeParameter desc
StringTitle string of a marker.
Method
public float getZIndex()
Obtains the z-index of a marker.


Parameters:
None.
Return:

Return typeParameter desc
floatZ-index, which indicates the overlapping order of a marker.
Method
public int hashCode()
Obtains the hash code of a marker.


Parameters:
None.
Return:

Return typeParameter desc
intHash code 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.


Parameters:
None.
Return:
None.


Method
public boolean isClusterable()
Obtains the cluster attribute of a marker.


Parameters:
None.
Return:

Return typeParameter desc
booleanIndicates whether a marker can be clustered. The options are true (yes) and false (no).



Method
public final boolean isDraggable()
Checks whether a marker can be dragged.


Parameters:
None.
Return:

Return typeParameter desc
booleanIf a marker can be dragged, true is returned. Otherwise, false is returned.
Method
public final boolean isFlat()
Checks whether a marker is flatly attached to the map.


Parameters:
None.
Return:

Return typeParameter desc
booleanIf a marker is flatly attached to the map, true is returned. If a marker faces the camera, false is returned.
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.


Parameters:
None.
Return:

Return typeParameter desc
booleanIf an information window is currently displayed, true is returned. Otherwise, false is returned.
Method
public final boolean isVisible()
Checks whether a marker is visible.


Parameters:
None.
Return:

Return typeParameter desc
booleanIf a marker is visible, true is returned. Otherwise, false is returned.
Method
public final void remove()
Removes a marker from the map.


Parameters:
None.
Return:
None.


Method
public final void setAlpha(float alpha)
Sets the opacity of a marker.


Parameters:

Parameter nameParameter desc
alphaOpacity. The value ranges from 0 (completely transparent) to 1 (completely opaque).


Return:
None.


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.This method has been deprecated. To set an anchor point, call setMarkerAnchor.


Parameters:

Parameter nameParameter desc
anchorUU coordinate of the anchor point of a marker. The value ranges from 0 to 1, expressed in a proportion of the marker image width.
anchorVV coordinate of the anchor point of a marker. The value ranges from 0 to 1, expressed in a proportion of the marker image height.


Return:
None.


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:

Parameter nameParameter desc
anchorUU coordinate of the anchor point of a marker. The value ranges from 0 to 1, expressed in a proportion of the marker image width.
anchorVV coordinate of the anchor point of a marker. The value ranges from 0 to 1, expressed in a proportion of the marker image height.


Return:
None.


Method
public final void setDraggable(boolean draggable)
Specifies whether a marker can be dragged.


Parameters:

Parameter nameParameter desc
draggableIndicates whether a marker can be dragged. The options are true (yes) and false (no).


Return:
None.


Method
public final void setFlat(boolean flat)
Specifies 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, 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:

Parameter nameParameter desc
flatIndicates whether to flatly attach a marker to the map. The options are true (flatly attaching to the map) and false (facing the camera). The default value is false.


Return:
None.


Method
public final void setIcon(BitmapDescriptor iconDescriptor)
Sets the icon of a marker. If null is passed, the default marker is used.


Parameters:

Parameter nameParameter desc
iconDescriptorObject containing an icon.


Return:
None.


Method
public final void setInfoWindowAnchor(float anchorU, float anchorV)
Sets the anchor point of the information window of a marker. The coordinate system used is the same as that of the anchor point of a marker. For details, please refer to the setAnchor(float anchorU, float anchorV) method. By default, the top-middle point of the information window is used as the anchor point.


Parameters:

Parameter nameParameter desc
anchorUU coordinate of the anchor point of an information window. The value ranges from 0 to 1, expressed in a proportion of the information window width.
anchorVV coordinate of the anchor point of an information window. The value ranges from 0 to 1, expressed in a proportion of the information window height.


Return:
None.


Method
public final void setPosition(LatLng latLng)
Sets the position of a marker.


Parameters:

Parameter nameParameter desc
latLngPosition coordinates of a marker.


Return:
None.


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:

Parameter nameParameter desc
rotationRotation angle of a marker. The default value is 0.


Return:
None.


Method
public final void setSnippet(String snippet)
Sets the text of a marker. If null is passed, the existing text is cleared.


Parameters:

Parameter nameParameter desc
snippetText.


Return:
None.


Method
public final void setTag(Object tag)
Sets the tag of a marker. If null is passed, the existing tag is cleared.


Parameters:

Parameter nameParameter desc
tagTag of a marker.


Return:
None.


Method
public final void setTitle(String title)
Sets the title of a marker. By default, the title is empty.


Parameters:

Parameter nameParameter desc
titleTitle string. If this parameter is set to null, the existing title is cleared.


Return:
None.


Method
public final void setVisible(boolean visible)
Specifies whether a marker is visible.


Parameters:

Parameter nameParameter desc
visibleIndicates whether a marker is visible. The options are true (yes) and false (no).


Return:
None.


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 in a random order. By default, the z-index is 0.


Parameters:

Parameter nameParameter desc
zIndexZ-index, which indicates the overlapping order of a marker.


Return:
None.


Method
public final void showInfoWindow()
Displays an information window for a marker.


Parameters:
None.
Return:
None.
Exception:

Exception TypeScenario
IllegalArgumentExceptionNo marker is displayed on the map.