java.lang.Object | |
↳ | com.amazon.geo.mapsv2.model.Marker |
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)
.
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Public constructor.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Gets the alpha (opacity) of the
Marker . | |||||||||||
Gets the unique ID for this
Marker . | |||||||||||
Gets a
LatLng representing the geographic position of the
Marker . | |||||||||||
Gets the rotation of the
Marker in degrees clockwise from the
default. | |||||||||||
Gets the snippet of the
Marker . | |||||||||||
Gets the title of the
Marker . | |||||||||||
Hides this
Marker 's info window if it is currently visible. | |||||||||||
Draggable markers are not supported in the Amazon Maps API.
| |||||||||||
Flat markers are not supported in the Amazon Maps API.
| |||||||||||
Retrieves a boolean value indicating whether the info window for the
Marker is currently displayed. | |||||||||||
Retrieves a boolean value indicating whether the
Marker is
visible or hidden. | |||||||||||
Removes this
Marker from the map. | |||||||||||
Sets the alpha (opacity) of the
Marker . | |||||||||||
Sets the anchor point for the
Marker 's image on Marker 's
position on the surface of the map. | |||||||||||
Draggable markers are not supported in the Amazon Maps API.
| |||||||||||
Flat markers are not supported in the Amazon Maps API.
| |||||||||||
Sets a custom icon for the
Marker as a BitmapDescriptor . | |||||||||||
Sets the anchor point for the
Marker 's info window on the marker's
image. | |||||||||||
Sets the geographic position of the
Marker . | |||||||||||
Sets the rotation of the
Marker measured in degrees clockwise
from the default position. | |||||||||||
Sets the snippet text of the
Marker . | |||||||||||
Sets the title of the
Marker . | |||||||||||
Sets the visibility of the
Marker . | |||||||||||
Shows this marker's info window if the
Marker is visible. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Public constructor. Instead of using this constructor, use
AmazonMap.addMarker(MarkerOptions)
to create a Marker
.
Gets the alpha (opacity) of the Marker
.
Marker
's alpha.
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.
Marker
's ID as a String
.
Gets a LatLng
representing the geographic position of the
Marker
.
LatLng
representing the position.
Gets the rotation of the Marker
in degrees clockwise from the
default.
Gets the snippet of the Marker
.
String
containing the snippet for the Marker
.
Gets the title of the Marker
.
String
containing the title for the Marker
.
Hides this Marker
's info window if it is currently visible.
Draggable markers are not supported in the Amazon Maps API.
Retrieves a boolean value indicating whether the the Marker
can
be dragged.
true
if the Marker
is draggable, false
otherwise.
Flat markers are not supported in the Amazon Maps API.
Retrieves a boolean value indicating whether the Marker
is
displayed as flat.
true
if the Marker
is flat, false
otherwise.
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.
true
if the info window is currently displayed, or
false
if it is hidden.
Retrieves a boolean value indicating whether the Marker
is
visible or hidden.
true
if the Marker
is visible, or false
if it is hidden.
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.
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.
alpha | The alpha value. |
---|
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---+
| | | | | | | | |
+---+---+ +---+---+---+---+---+
| | | | | | | | |
+---+---+ +---+---+---+---+---+
| | | | | |
+---+---+---+---+---+
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]. |
Draggable markers are not supported in the Amazon Maps API.
Sets the draggable option for the Marker
. The
default is false
.
draggable | true to enable dragging, false to
disable it.
|
---|
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
.
flat | true to make the marker flat, false to
display the marker normally.
|
---|
Sets a custom icon for the Marker
as a BitmapDescriptor
.
Use defaultMarker()
for the default
marker.
icon | The icon to use for this marker. Must not be null .
|
---|
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).
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]. |
Sets the geographic position of the Marker
. You
can change this on an existing Marker
to move the icon on the
map.
latlng | The position on the map as a LatLng . Must not be
null .
|
---|
Sets the rotation of the Marker
measured in degrees clockwise
from the default position. The default is zero, pointing straight up.
rotation | The rotation in degrees. |
---|
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.
snippet | The snippet text for the Marker .
|
---|
Sets the title of the Marker
. When using the default info window,
the title text is displayed as the title of the window.
title | The title text for the Marker .
|
---|
Sets the visibility of the Marker
. The default value is true
.
visible | true to make the Marker visible, or false
to make it invisible.
|
---|
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)
.