public final class

Marker

extends Object
java.lang.Object
   ↳ com.amazon.geo.mapsv2.model.Marker

Class Overview

An icon overlay that can be displayed at a specific geographic location on the map. A Marker is drawn in relation to the screen rather than the map's surface; rotating, zooming, or tilting the map does not change the orientation or appearance of the icon.

Obtain a Marker by creating a MarkerOptions object with the initial marker properties and then passing it to addMarker(MarkerOptions).

You can change the properties of the Marker using the setter methods after the Marker is created. Note that all getter and setter methods must be called on the main thread or an IllegalStateException is thrown.

A Marker can use a default "pin" icon, a default icon with a custom color, or a custom bitmap in place of the default icon. Set the icon for a marker with setIcon(BitmapDescriptor) or MarkerOptions.icon(BitmapDescriptor).

Clicking a Marker displays a default info window if the object has a title defined. You can provide a custom window by implementing AmazonMap.InfoWindowAdapter and assigning it with setInfoWindowAdapter(InfoWindowAdapter).

You can change the default marker click behavior by implementing AmazonMap.OnMarkerClickListener and assigning it with setOnMarkerClickListener(AmazonMap.OnMarkerClickListener).

Summary

Public Constructors
Marker(IMarkerDelegate markerDelegate)
Public constructor.
Public Methods
boolean equals(Object obj)
float getAlpha()
Gets the alpha (opacity) of the Marker.
String getId()
Gets the unique ID for this Marker.
LatLng getPosition()
Gets a LatLng representing the geographic position of the Marker.
float getRotation()
Gets the rotation of the Marker in degrees clockwise from the default.
String getSnippet()
Gets the snippet of the Marker.
String getTitle()
Gets the title of the Marker.
int hashCode()
void hideInfoWindow()
Hides this Marker's info window if it is currently visible.
boolean isDraggable()
Draggable markers are not supported in the Amazon Maps API.
boolean isFlat()
Flat markers are not supported in the Amazon Maps API.
boolean isInfoWindowShown()
Retrieves a boolean value indicating whether the info window for the Marker is currently displayed.
boolean isVisible()
Retrieves a boolean value indicating whether the Marker is visible or hidden.
void remove()
Removes this Marker from the map.
void setAlpha(float alpha)
Sets the alpha (opacity) of the Marker.
void setAnchor(float anchorU, float anchorV)
Sets the anchor point for the Marker's image on Marker's position on the surface of the map.
void setDraggable(boolean draggable)
Draggable markers are not supported in the Amazon Maps API.
void setFlat(boolean flat)
Flat markers are not supported in the Amazon Maps API.
void setIcon(BitmapDescriptor icon)
Sets a custom icon for the Marker as a BitmapDescriptor.
void setInfoWindowAnchor(float anchorU, float anchorV)
Sets the anchor point for the Marker's info window on the marker's image.
void setPosition(LatLng latlng)
Sets the geographic position of the Marker.
void setRotation(float rotation)
Sets the rotation of the Marker measured in degrees clockwise from the default position.
void setSnippet(String snippet)
Sets the snippet text of the Marker.
void setTitle(String title)
Sets the title of the Marker.
void setVisible(boolean visible)
Sets the visibility of the Marker.
void showInfoWindow()
Shows this marker's info window if the Marker is visible.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public Marker (IMarkerDelegate markerDelegate)

Public constructor. Instead of using this constructor, use AmazonMap.addMarker(MarkerOptions) to create a Marker.

Public Methods

public boolean equals (Object obj)

public float getAlpha ()

Gets the alpha (opacity) of the Marker.

Returns
  • The Marker's alpha.

public String getId ()

Gets the unique ID for this Marker. The ID is unique for all Marker objects currently added to the map. This method may be called on a background thread.

Returns
  • This Marker's ID as a String.

public LatLng getPosition ()

Gets a LatLng representing the geographic position of the Marker.

Returns
  • A LatLng representing the position.

public float getRotation ()

Gets the rotation of the Marker in degrees clockwise from the default.

Returns
  • The rotation of the marker in degrees clockwise from the default.

public String getSnippet ()

Gets the snippet of the Marker.

Returns
  • A String containing the snippet for the Marker.

public String getTitle ()

Gets the title of the Marker.

Returns
  • A String containing the title for the Marker.

public int hashCode ()

public void hideInfoWindow ()

Hides this Marker's info window if it is currently visible.

public boolean isDraggable ()

Draggable markers are not supported in the Amazon Maps API.

Retrieves a boolean value indicating whether the the Marker can be dragged.

Returns
  • true if the Marker is draggable, false otherwise.

public boolean isFlat ()

Flat markers are not supported in the Amazon Maps API.

Retrieves a boolean value indicating whether the Marker is displayed as flat.

Returns
  • true if the Marker is flat, false otherwise.

public boolean isInfoWindowShown ()

Retrieves a boolean value indicating whether the info window for the Marker is currently displayed. Note that this does not consider whether the info window is actually visible on screen or not.

Returns
  • true if the info window is currently displayed, or false if it is hidden.

public boolean isVisible ()

Retrieves a boolean value indicating whether the Marker is visible or hidden.

Returns
  • true if the Marker is visible, or false if it is hidden.

public void remove ()

Removes this Marker from the map. After calling this method, calling other methods on the object has no effect on the appearance of the map.

public void setAlpha (float alpha)

Sets the alpha (opacity) of the Marker. Alpha is a value in the closed range [0, 1]. Use 0 to make the Marker completely transparent, or 1 to make it completely opaque. The default is 1.

Parameters
alpha The alpha value.

public void setAnchor (float anchorU, float anchorV)

Sets the anchor point for the Marker's image on Marker's position on the surface of the map. The default is the bottom middle of the image (0.5, 1).

Anchor coordinates (U, V) are defined in the continuous space [0.0, 1.0] x [0.0, 1.0]. U corresponds to a percentage of an image's width and is measured from the left edge of the image. V corresponds to a percentage of an image's height and is measured from the top edge of the image. So the coordinate (0, 0) is the top left corner of the image and (1, 1) is the bottom right corner of the image.

The anchor point of an image with width W pixels and height H pixels is the nearest point in a discrete (W + 1) x (H + 1) grid. This is obtained by first scaling U and V then rounding to the nearest pixel.

 X = round(U * W)
 Y = round(V * H)
 
 

For example, consider two images. The first is 2x4 pixels and the second is 5x5 pixels. Both have anchor coordinates (U, V) of (0.8, 0.3).

In the first image, this resolves to (round(0.8 * 2), round(0.3 * 4)) = (2, 1).

In the second image, this resolves to (round(0.8 * 5), round(0.3 * 5)) = (4, 2).

 Image 1: (X, Y) = (2, 1)          Image 2: (X, Y) = (4, 2)
 +---+---+                         +---+---+---+---+---+
 |   |   |                         |   |   |   |   |   |
 +---+---X                         +---+---+---+---+---+
 |   |   |                         |   |   |   |   |   |
 +---+---+                         +---+---+---+---X---+
 |   |   |                         |   |   |   |   |   |
 +---+---+                         +---+---+---+---+---+
 |   |   |                         |   |   |   |   |   |
 +---+---+                         +---+---+---+---+---+
                                   |   |   |   |   |   |
                                   +---+---+---+---+---+
 
 

Parameters
anchorU The U coordinate where the image should be anchored, as a ratio to the image width and measured from the left edge. Should be in the closed range [0, 1].
anchorV The V coordinate where the image should be anchored, as a ratio to the image height and measured from the top edge. Should be in the closed range [0, 1].

public void setDraggable (boolean draggable)

Draggable markers are not supported in the Amazon Maps API.

Sets the draggable option for the Marker. The default is false.

Parameters
draggable true to enable dragging, false to disable it.

public void setFlat (boolean flat)

Flat markers are not supported in the Amazon Maps API.

Sets the flat option for the Marker. This determines whether the Marker is displayed as flat against the map. The default is false.

Parameters
flat true to make the marker flat, false to display the marker normally.

public void setIcon (BitmapDescriptor icon)

Sets a custom icon for the Marker as a BitmapDescriptor. Use defaultMarker() for the default marker.

Parameters
icon The icon to use for this marker. Must not be null.

public void setInfoWindowAnchor (float anchorU, float anchorV)

Sets the anchor point for the Marker's info window on the marker's image. See setAnchor(float, float) for more information about anchor points. The default is the top middle (0.5, 0).

Parameters
anchorU The U coordinate where the info window should be anchored, as a ratio to the image width and measured from the left edge. Should be in the closed range [0, 1].
anchorV The V coordinate where the info window should be anchored, as a ratio to the image height and measured from the top edge. Should be in the closed range [0, 1].

public void setPosition (LatLng latlng)

Sets the geographic position of the Marker. You can change this on an existing Marker to move the icon on the map.

Parameters
latlng The position on the map as a LatLng. Must not be null.

public void setRotation (float rotation)

Sets the rotation of the Marker measured in degrees clockwise from the default position. The default is zero, pointing straight up.

Parameters
rotation The rotation in degrees.

public void setSnippet (String snippet)

Sets the snippet text of the Marker. When using the default info window, the snippet text is displayed in the body of the window beneath the title.

Parameters
snippet The snippet text for the Marker.

public void setTitle (String title)

Sets the title of the Marker. When using the default info window, the title text is displayed as the title of the window.

Parameters
title The title text for the Marker.

public void setVisible (boolean visible)

Sets the visibility of the Marker. The default value is true.

Parameters
visible true to make the Marker visible, or false to make it invisible.

public void showInfoWindow ()

Shows this marker's info window if the Marker is visible.

Note that the default info window is only shown when the Marker has a title. If the Marker does not have a title, this method does nothing.

You can provide a custom window by implementing AmazonMap.InfoWindowAdapter and assigning it with setInfoWindowAdapter(InfoWindowAdapter).