# Marker

public class **Marker** extends [Object](https://developer.android.com/reference/java/lang/Object.html)  

|---|---|---|
| Known Direct Subclasses [AdvancedMarker](https://developers.google.com/android/reference/com/google/android/gms/maps/model/AdvancedMarker) |---|---| | [AdvancedMarker](https://developers.google.com/android/reference/com/google/android/gms/maps/model/AdvancedMarker) | Extends `https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker`, and provides additional premium features. | |||

An icon placed at a particular point on the map's surface. A marker icon is drawn oriented
against the device's screen rather than the map's surface; i.e., it will not necessarily
change orientation due to map rotations, tilting, or zooming.

A marker has the following properties:

Alpha
:   Sets the opacity of the marker. Defaults to 1.0.

Anchor
:   The point on the image that will be placed at the `https://developers.google.com/android/reference/com/google/android/gms/maps/model/LatLng`
    position of the marker. This defaults to 50% from the left of the image and at the bottom
    of the image.

Position
:   The `https://developers.google.com/android/reference/com/google/android/gms/maps/model/LatLng` value
    for the marker's position on the map. You can change this value at any time if you want to
    move the marker.

Title
:   A text string that's displayed in an info window when the user taps the marker. You can
    change this value at any time.

Snippet
:   Additional text that's displayed below the title. You can change this value at any
    time.

Icon
:   A bitmap that's displayed for the marker. If the icon is left unset, a default icon is
    displayed. You can specify an alternative coloring of the default icon using `https://developers.google.com/android/reference/com/google/android/gms/maps/model/BitmapDescriptorFactory#defaultMarker(float)`.

Drag Status
:   If you want to allow the user to drag the marker, set this property to
    `true`. You can change this value at any time. The default is
    `false`.

Visibility
:   By default, the marker is visible. To make the marker invisible, set this property to
    `false`. You can change this value at any time.

Flat or Billboard
:   If the marker is flat against the map, it will always be drawn facing the camera and
    will rotate and tilt with the camera, unlike a `https://developers.google.com/android/reference/com/google/android/gms/maps/model/GroundOverlay`.
    If the marker is a billboard, it will remain stuck to the map as the camera rotates and
    tilts. As with flat markers, billboard markers retain their size when the map is zoomed in
    or out. The default is a billboard (`false`)

Rotation
:   The rotation of the marker in degrees clockwise about the marker's anchor point. The
    axis of rotation is perpendicular to the marker. A rotation of 0 corresponds to the default
    position of the marker. When the marker is flat on the map, the default position is North
    aligned and the rotation is such that the marker always remains flat on the map. When the
    marker is a billboard, the default position is pointing up and the rotation is such that
    the marker is always facing the camera. The default value is 0.

zIndex
:   The draw order for the marker. The markers are drawn in order of the zIndex, with the
    highest zIndex marker drawn on top. By setting the zIndex property for each marker, you can
    control which tap target your user is most likely to hit. The default value is 0.

Tag
:   An `Object` associated with the marker. For example, the `Object`
    can contain data about what the marker represents. This is easier than storing a separate
    `Map<Marker, Object>`. As another example, you can associate a
    `String` ID corresponding to the ID from a data set. Google Maps SDK for Android
    neither reads nor writes this property.

Methods in this class must be called on the Android UI thread. If not, an `https://developer.android.com/reference/java/lang/IllegalStateException.html`
will be thrown at runtime.

### Example

    GoogleMap map = ... // get a map.
     // Add a marker at San Francisco.
     Marker marker = map.addMarker(new MarkerOptions()
         .position(new LatLng(37.7750, 122.4183))
         .title("San Francisco")
         .snippet("Population: 776733"));
     
### Developer Guide

For more information, read the [Markers](https://developers.google.com/maps/documentation/android-sdk/marker) developer
guide.

### Public Method Summary

|---|---|
| boolean | [equals](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#equals(java.lang.Object))([Object](https://developer.android.com/reference/java/lang/Object.html) other) Tests if this `https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker` is equal to another. |
| float | [getAlpha](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#getAlpha())() Gets the alpha of the marker. |
| [String](https://developer.android.com/reference/java/lang/String.html) | [getId](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#getId())() Gets this marker's id. |
| [LatLng](https://developers.google.com/android/reference/com/google/android/gms/maps/model/LatLng) | [getPosition](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#getPosition())() Returns the position of the marker. |
| float | [getRotation](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#getRotation())() Gets the rotation of the marker. |
| [String](https://developer.android.com/reference/java/lang/String.html) | [getSnippet](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#getSnippet())() Gets the snippet of the marker. |
| [Object](https://developer.android.com/reference/java/lang/Object.html) | [getTag](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#getTag())() Gets the tag for the marker. |
| [String](https://developer.android.com/reference/java/lang/String.html) | [getTitle](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#getTitle())() Gets the title of the marker. |
| float | [getZIndex](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#getZIndex())() Returns the zIndex of the marker. |
| int | [hashCode](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#hashCode())() |
| void | [hideInfoWindow](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#hideInfoWindow())() Hides the info window if it is shown from this marker. |
| boolean | [isDraggable](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#isDraggable())() Gets the draggability of the marker. |
| boolean | [isFlat](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#isFlat())() Gets the flat setting of the Marker. |
| boolean | [isInfoWindowShown](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#isInfoWindowShown())() Returns whether the info window is currently shown above this marker. |
| boolean | [isVisible](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#isVisible())() Gets the visibility setting of this marker. |
| void | [remove](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#remove())() Removes this marker from the map. |
| void | [setAlpha](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#setAlpha(float))(float alpha) Sets the alpha (opacity) of the marker. |
| void | [setAnchor](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#setAnchor(float,%20float))(float anchorU, float anchorV) Sets the anchor point for the marker. |
| void | [setDraggable](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#setDraggable(boolean))(boolean draggable) Sets the draggability of the marker. |
| void | [setFlat](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#setFlat(boolean))(boolean flat) Sets whether this marker should be flat against the map `true` or a billboard facing the camera `false`. |
| void | [setIcon](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#setIcon(com.google.android.gms.maps.model.BitmapDescriptor))([BitmapDescriptor](https://developers.google.com/android/reference/com/google/android/gms/maps/model/BitmapDescriptor) iconDescriptor) Sets the icon for the marker. |
| void | [setInfoWindowAnchor](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#setInfoWindowAnchor(float,%20float))(float anchorU, float anchorV) Specifies the point in the marker image at which to anchor the info window when it is displayed. |
| void | [setPosition](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#setPosition(com.google.android.gms.maps.model.LatLng))([LatLng](https://developers.google.com/android/reference/com/google/android/gms/maps/model/LatLng) latlng) Sets the location of the marker. |
| void | [setRotation](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#setRotation(float))(float rotation) Sets the rotation of the marker in degrees clockwise about the marker's anchor point. |
| void | [setSnippet](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#setSnippet(java.lang.String))([String](https://developer.android.com/reference/java/lang/String.html) snippet) Sets the snippet of the marker. |
| void | [setTag](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#setTag(java.lang.Object))([Object](https://developer.android.com/reference/java/lang/Object.html) tag) Sets the tag for the marker. |
| void | [setTitle](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#setTitle(java.lang.String))([String](https://developer.android.com/reference/java/lang/String.html) title) Sets the title of the marker. |
| void | [setVisible](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#setVisible(boolean))(boolean visible) Sets the visibility of this marker. |
| void | [setZIndex](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#setZIndex(float))(float zIndex) Sets the zIndex of the marker. |
| void | [showInfoWindow](https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#showInfoWindow())() Shows the info window of this marker on the map, if this marker `https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#isVisible()`. |

### Inherited Method Summary

From class java.lang.Object

|---|---|
| [Object](https://developer.android.com/reference/java/lang/Object.html) | clone() |
| boolean | equals([Object](https://developer.android.com/reference/java/lang/Object.html) arg0) |
| void | finalize() |
| final [Class](https://developer.android.com/reference/java/lang/Class.html)\<?\> | getClass() |
| int | hashCode() |
| final void | notify() |
| final void | notifyAll() |
| [String](https://developer.android.com/reference/java/lang/String.html) | toString() |
| final void | wait(long arg0, int arg1) |
| final void | wait(long arg0) |
| final void | wait() |

## Public Methods

#### public boolean **equals** ([Object](https://developer.android.com/reference/java/lang/Object.html) other)

Tests if this `https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker` is
equal to another.

##### Parameters

| other | an `https://developer.android.com/reference/java/lang/Object.html`. |
|---|---|

##### Returns

- true if both objects are the same object, that is, this == other.

#### public float **getAlpha** ()

Gets the alpha of the marker.

##### Returns

- the alpha of the marker in the range \[0, 1\].

#### public [String](https://developer.android.com/reference/java/lang/String.html) **getId** ()

Gets this marker's id. The id will be unique amongst all Markers on a map.

##### Returns

- this marker's id.

#### public [LatLng](https://developers.google.com/android/reference/com/google/android/gms/maps/model/LatLng)
**getPosition** ()

Returns the position of the marker.

##### Returns

- A `https://developers.google.com/android/reference/com/google/android/gms/maps/model/LatLng` object specifying the marker's current position.

#### public float **getRotation** ()

Gets the rotation of the marker.

##### Returns

- the rotation of the marker in degrees clockwise from the default position.

#### public [String](https://developer.android.com/reference/java/lang/String.html) **getSnippet** ()

Gets the snippet of the marker.

##### Returns

- A string containing the marker's snippet, or `null` if no snippet has been set.

#### public [Object](https://developer.android.com/reference/java/lang/Object.html) **getTag** ()

Gets the tag for the marker.

##### Returns

- the tag if a tag was set with `setTag`; `null` if no tag has been set.

#### public [String](https://developer.android.com/reference/java/lang/String.html) **getTitle** ()

Gets the title of the marker.

##### Returns

- A string containing the marker's title, or `null` if no title has been set.

#### public float **getZIndex** ()

Returns the zIndex of the marker.

##### Returns

- this marker's zIndex.

#### public int **hashCode** ()

#### public void **hideInfoWindow** ()

Hides the info window if it is shown from this marker.

This method has no effect if this marker is not visible.

#### public boolean **isDraggable** ()

Gets the draggability of the marker. When a marker is draggable, it can be moved by
the user by long pressing on the marker.

##### Returns

- `true` if the marker is draggable; otherwise, returns `false`.

#### public boolean **isFlat** ()

Gets the flat setting of the Marker.

##### Returns

- `true` if the marker is flat against the map; `false` if the marker should face the camera.

#### public boolean **isInfoWindowShown** ()

Returns whether the info window is currently shown above this marker. This does not
consider whether or not the info window is actually visible on screen.

#### public boolean **isVisible** ()

Gets the visibility setting of this marker. Note that this does not indicate whether
the marker is within the screen's viewport. It indicates whether the marker will be
drawn if it is contained in the screen's viewport.

##### Returns

- this marker's visibility.

#### public void **remove** ()

Removes this marker from the map. After a marker has been removed, the behavior of
all its methods is undefined.

#### public void **setAlpha** (float alpha)

Sets the alpha (opacity) of the marker. This is a value from 0 to 1, where 0 means
the marker is completely transparent and 1 means the marker is completely opaque.

#### public void **setAnchor** (float anchorU, float anchorV)

Sets the anchor point for the marker.

The anchor specifies the point in the icon image that is anchored to the marker's
position on the Earth's surface.

The anchor point is specified in the continuous space \[0.0, 1.0\] x \[0.0, 1.0\], where
(0, 0) is the top-left corner of the image, and (1, 1) is the bottom-right corner. The
anchoring point in a *W* x *H* image is the nearest discrete grid point
in a *(W + 1)* x *(H + 1)* grid, obtained by scaling the then rounding.
For example, in a 4 x 2 image, the anchor point (0.7, 0.6) resolves to the grid point
at (3, 1).

```
 *---+---+---+---*
 |     |     |     |     |
 |     |     |     |     |
 +---+---+---+---+
 |     |     |   X |     |   (U, V) = (0.7, 0.6)
 |     |     |     |     |
 *---+---+---+---*

 *---+---+---+---*
 |     |     |     |     |
 |     |     |     |     |
 +---+---+---X---+   (X, Y) = (3, 1)
 |     |     |     |     |
 |     |     |     |     |
 *---+---+---+---*
 
```

##### Parameters

| anchorU | u-coordinate of the anchor, as a ratio of the image width (in the range \[0, 1\]). |
| anchorV | v-coordinate of the anchor, as a ratio of the image height (in the range \[0, 1\]). |
|---|---|

#### public void **setDraggable** (boolean draggable)

Sets the draggability of the marker. When a marker is draggable, it can be moved by
the user by long pressing on the marker.

#### public void **setFlat** (boolean flat)

Sets whether this marker should be flat against the map `true` or a
billboard facing the camera `false`.

#### public void **setIcon** ([BitmapDescriptor](https://developers.google.com/android/reference/com/google/android/gms/maps/model/BitmapDescriptor) iconDescriptor)

Sets the icon for the marker.

##### Parameters

| iconDescriptor | if null, the default marker is used. |
|---|---|

#### public void **setInfoWindowAnchor** (float anchorU, float anchorV)

Specifies the point in the marker image at which to anchor the info window when it
is displayed. This is specified in the same coordinate system as the anchor. See
`https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#setAnchor(float,%20float)` for more details. The default is the top middle of
the image.

##### Parameters

| anchorU | u-coordinate of the info window anchor, as a ratio of the image width (in the range \[0, 1\]). |
| anchorV | v-coordinate of the info window anchor, as a ratio of the image height (in the range \[0, 1\]). |
|---|---|

#### public void **setPosition** ([LatLng](https://developers.google.com/android/reference/com/google/android/gms/maps/model/LatLng) latlng)

Sets the location of the marker.

#### public void **setRotation** (float rotation)

Sets the rotation of the marker in degrees clockwise about the marker's anchor
point. The axis of rotation is perpendicular to the marker. A rotation of 0 corresponds
to the default position of the marker.

#### public void **setSnippet** ([String](https://developer.android.com/reference/java/lang/String.html) snippet)

Sets the snippet of the marker.

##### Parameters

| snippet | if null, the snippet is cleared. |
|---|---|

#### public void **setTag** ([Object](https://developer.android.com/reference/java/lang/Object.html) tag)

Sets the tag for the marker.

You can use this property to associate an arbitrary `Object` with this
marker. For example, the `Object` can contain data about what the marker
represents. This is easier than storing a separate `Map<Marker,
Object>`. As another example, you can associate a `String` ID
corresponding to the ID from a data set. Google Maps SDK for Android neither reads nor
writes this property. It is your responsibility to call `setTag(null)` to
clear the tag when you no longer need it, to prevent memory leaks in your app.

##### Parameters

| tag | if null, the tag is cleared. |
|---|---|

#### public void **setTitle** ([String](https://developer.android.com/reference/java/lang/String.html) title)

Sets the title of the marker.

##### Parameters

| title | if null, the title is cleared. |
|---|---|

#### public void **setVisible** (boolean visible)

Sets the visibility of this marker. If set to `false` and an info window
is currently showing for this marker, this will hide the info window.

#### public void **setZIndex** (float zIndex)

Sets the zIndex of the marker.

#### public void **showInfoWindow** ()

Shows the info window of this marker on the map, if this marker `https://developers.google.com/android/reference/com/google/android/gms/maps/model/Marker#isVisible()`.

##### Throws

| [IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html) | if `marker` is not on this map |
|---|---|