java.lang.Object | ||
↳ | com.neomades.maps.overlay.BaseOverlay | |
↳ | com.neomades.maps.overlay.Marker |
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.
Sets the opacity of the marker. Defaults to 1.0.
The point on the image that will be placed at the LatLng position of the marker. This defaults to 50% from the left of the image and at the bottom of the image.
The 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.
A text string that's displayed in an info window when the user taps the marker. You can change this value at any time.
Additional text that's displayed below the title. You can change this value at any time.
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 #setHue(int).
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.
By default, the marker is visible. To make the marker invisible, set this property to false. You can change this value at any time.
If the marker is flat against the map, it will remain stuck to the map as the camera rotates and tilts but will still remain the same size as the camera zooms, unlike a GroundOverlay. If the marker is a billboard, it will always be drawn facing the camera and will rotate and tilt with the camera. The default is a billboard (false)
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.
Example
Map map = ... // get a map. // Add a marker at San Francisco. Marker marker = new Marker(new Location(37.7750, 122.4183)) .setTitle("San Francisco") .setSnippet("Population: 776733"); map.addMarker(marker);
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Marker(Location loc)
Creates a new Marker.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
float |
getAlpha()
Gets the alpha of the marker.
| ||||||||||
Location |
getPosition()
Returns the position of the marker.
| ||||||||||
float |
getRotation()
Gets the rotation of the marker.
| ||||||||||
String |
getSnippet()
Gets the snippet of the marker.
| ||||||||||
String |
getTitle()
Gets the title of the marker.
| ||||||||||
void |
hideInfoWindow()
Hides the info window if it is shown from this marker.
| ||||||||||
boolean |
isDraggable()
Gets the draggability of the marker.
| ||||||||||
boolean |
isFlat()
Gets the flat setting of the Marker.
| ||||||||||
boolean |
isInfoWindowShown()
Returns whether the info window is currently shown above this marker.
| ||||||||||
Marker |
setAlpha(float alpha)
Sets the alpha (opacity) of the marker.
| ||||||||||
Marker |
setAnchor(float anchorU, float anchorV)
Sets the anchor point for the marker.
| ||||||||||
Marker |
setDraggable(boolean draggable)
Sets the draggability of the marker.
| ||||||||||
Marker |
setFlat(boolean flat)
Sets whether this marker should be flat against the map true or a billboard
facing the camera false.
| ||||||||||
Marker |
setIcon(MarkerIcon icon)
Sets the icon for the marker.
| ||||||||||
Marker |
setIdentifier(String identifier)
Sets an identifier to this marker.
| ||||||||||
Marker |
setInfoWindowAnchor(float anchorU, float anchorV)
Specifies the point in the marker image at which to anchor the info window
when it is displayed.
| ||||||||||
Marker |
setPosition(Location position)
Sets the position of the marker.
| ||||||||||
Marker |
setRotation(float rotation)
Sets the rotation of the marker in degrees clockwise about the marker's
anchor point.
| ||||||||||
Marker |
setSnippet(String snippet)
Sets the snippet of the marker.
| ||||||||||
Marker |
setTitle(String title)
Sets the title of the marker.
| ||||||||||
Marker |
setVisible(boolean visible)
Sets the visibility of this marker.
| ||||||||||
void |
showInfoWindow()
Shows the info window of this marker on the map, if this marker isVisible().
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Gets the alpha of the marker.
Returns the position of the marker.
Gets the rotation of the marker.
Gets the snippet of the marker.
Gets the title of the marker.
Hides the info window if it is shown from this marker.
This method has no effect if this marker is not visible.
Gets the draggability of the marker. When a marker is draggable, it can be moved by the user by long pressing on the marker.
Gets the flat setting of the Marker.
Available only for the Android
platform. Returns false for the
other platforms.
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.
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.
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 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) | | | | | | | | | | +-----+-----+-----+-----+
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]) |
Sets the draggability of the marker. When a marker is draggable, it can be moved by the user by long pressing on the marker.
Sets whether this marker should be flat against the map true or a billboard facing the camera false.
Available only for the Android
platform.
Sets the icon for the marker.
By default, the marker has a default icon, which look is platform-dependent.
A MarkerIcon
can be obtained through MarkerIconFactory
.
The platform default MarkerIcon
can be retrieved with
defaultIcon()
.
If the same icon is to be used on multiple markers, use a single
MarkerIcon
instance to save memory.
icon | the icon to apply to the marker (must not be null) |
---|
NullPointerException | if the parameter is null |
---|
Sets an identifier to this marker. This will enable the system to optimize the usage of the marker. When a new marker is created, if it has the same identifier as an existing one, it can be reused instead of allocating a new marker. This is particularly useful if some markers share the same icon.
identifier | the marker identifier |
---|
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 setAnchor(float, float) for more details. The default is the top middle of the image.
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]) |
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.
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.
Shows the info window of this marker on the map, if this marker isVisible().
IllegalArgumentException | if marker is not on this map |
---|