public final class

MarkerOptions

extends Object
implements Parcelable
java.lang.Object
   ↳ com.google.android.gms.maps.model.MarkerOptions

Class Overview

Defines MarkerOptions for a marker.

Developer Guide

For more information, read the Markers developer guide.

Summary

Constants
String NULL
[Expand]
Inherited Constants
From interface android.os.Parcelable
Fields
public static final MarkerOptionsCreator CREATOR
Public Constructors
MarkerOptions()
Creates a new set of marker options.
Public Methods
MarkerOptions anchor(float u, float v)
Specifies the anchor to be at a particular point in the marker image.
int describeContents()
MarkerOptions draggable(boolean draggable)
Sets the draggability for the marker.
float getAnchorU()
Horizontal distance, normalized to [0, 1], of the anchor from the left edge.
float getAnchorV()
Vertical distance, normalized to [0, 1], of the anchor from the top edge.
BitmapDescriptor getIcon()
Gets the custom icon set for this MarkerOptions object.
LatLng getPosition()
Returns the position set for this MarkerOptions object.
String getSnippet()
Gets the snippet set for this MarkerOptions object.
String getTitle()
Gets the title set for this MarkerOptions object.
MarkerOptions icon(BitmapDescriptor icon)
Sets the icon for the marker.
boolean isDraggable()
Gets the draggability setting for this MarkerOptions object.
boolean isVisible()
Gets the visibility setting for this MarkerOptions object.
MarkerOptions position(LatLng position)
Sets the location for the marker.
MarkerOptions snippet(String snippet)
Sets the snippet for the marker.
MarkerOptions title(String title)
Sets the title for the marker.
MarkerOptions visible(boolean visible)
Sets the visibility for the marker.
void writeToParcel(Parcel out, int flags)
[Expand]
Inherited Methods
From class java.lang.Object
From interface android.os.Parcelable

Constants

public static final String NULL

Constant Value: "SAFE_PARCELABLE_NULL_STRING"

Fields

public static final MarkerOptionsCreator CREATOR

Public Constructors

public MarkerOptions ()

Creates a new set of marker options.

Public Methods

public MarkerOptions anchor (float u, float v)

Specifies the anchor to be at a particular point in the marker image.

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
u u-coordinate of the anchor, as a ratio of the image width (in the range [0, 1])
v v-coordinate of the anchor, as a ratio of the image height (in the range [0, 1])
Returns
  • the object for which the method was called, with the new anchor set.

public int describeContents ()

public MarkerOptions draggable (boolean draggable)

Sets the draggability for the marker.

Returns
  • the object for which the method was called, with the new draggable state set.

public float getAnchorU ()

Horizontal distance, normalized to [0, 1], of the anchor from the left edge.

Returns
  • the u value of the anchor.

public float getAnchorV ()

Vertical distance, normalized to [0, 1], of the anchor from the top edge.

Returns
  • the v value of the anchor.

public BitmapDescriptor getIcon ()

Gets the custom icon set for this MarkerOptions object.

Returns
  • An BitmapDescriptor representing the custom icon, or null if no custom icon is set.

public LatLng getPosition ()

Returns the position set for this MarkerOptions object.

Returns
  • A LatLng object specifying the marker's current position.

public String getSnippet ()

Gets the snippet set for this MarkerOptions object.

Returns
  • A string containing the marker's snippet.

public String getTitle ()

Gets the title set for this MarkerOptions object.

Returns
  • A string containing the marker's title.

public MarkerOptions icon (BitmapDescriptor icon)

Sets the icon for the marker.

Parameters
icon if null, the default marker is used.
Returns
  • the object for which the method was called, with the new icon set.

public boolean isDraggable ()

Gets the draggability setting for this MarkerOptions object.

Returns
  • true if the marker is draggable; otherwise, returns false.

public boolean isVisible ()

Gets the visibility setting for this MarkerOptions object.

Returns
  • true if the marker is visible; otherwise, returns false.

public MarkerOptions position (LatLng position)

Sets the location for the marker.

Returns
  • the object for which the method was called, with the new position set.

public MarkerOptions snippet (String snippet)

Sets the snippet for the marker.

Returns
  • the object for which the method was called, with the new snippet set.

public MarkerOptions title (String title)

Sets the title for the marker.

Returns
  • the object for which the method was called, with the new title set.

public MarkerOptions visible (boolean visible)

Sets the visibility for the marker.

Returns
  • the object for which the method was called, with the new visibility state set.

public void writeToParcel (Parcel out, int flags)