Marker

class Marker(position: LatLng, title: String? = null, snippet: String? = null, icon: BitmapDescriptor? = null, anchor: Pair<Float, Float> = Pair(0.5f, 1.0f), infoWindowAnchor: Pair<Float, Float> = Pair(0.5f, 0.0f), rotation: Float = 0.0f, isFlat: Boolean = false, visible: Boolean = true, alpha: Float = 1.0f, draggable: Boolean = false, zIndex: Float = 0.0f, tag: Any? = null)(source)

A marker on the map at a specific geographic location.

The marker returned by OpenMapView.addMarker is a live handle, as in the Maps SDK: setting a property redraws the map right away, and remove takes the marker off the map.

Parameters

position

The geographic location of the marker

title

Optional title text displayed when marker is clicked

snippet

Optional snippet text displayed below the title

icon

Custom icon descriptor. If null, a default red marker icon will be used

anchor

Anchor point for the marker icon. Default (0.5f, 1.0f) means the marker is centered horizontally and anchored at the bottom

infoWindowAnchor

The point of the icon the info window points at, as fractions of its width and height. Default (0.5f, 0.0f) is the top center

rotation

Clockwise rotation of the icon around the anchor, in degrees: relative to the screen, or to north for a flat icon. Default is 0

isFlat

Whether the icon lies flat on the map and turns with it when the camera has a bearing, instead of facing the screen. Default is false

visible

Whether the marker is visible. Default is true

alpha

Opacity of the marker from 0.0 (transparent) to 1.0 (opaque). Default is 1.0

draggable

Whether the marker can be dragged. Default is false

zIndex

Draw order. Markers with higher zIndex are drawn on top. Default is 0.0

tag

Optional user data associated with the marker

Constructors

Link copied to clipboard
constructor(position: LatLng, title: String? = null, snippet: String? = null, icon: BitmapDescriptor? = null, anchor: Pair<Float, Float> = Pair(0.5f, 1.0f), infoWindowAnchor: Pair<Float, Float> = Pair(0.5f, 0.0f), rotation: Float = 0.0f, isFlat: Boolean = false, visible: Boolean = true, alpha: Float = 1.0f, draggable: Boolean = false, zIndex: Float = 0.0f, tag: Any? = null)

Properties

Link copied to clipboard

Opacity from 0.0 (transparent) to 1.0 (opaque)

Link copied to clipboard

The point of the icon at position, as fractions of its width and height

Link copied to clipboard

Whether the marker can be dragged

Link copied to clipboard

Custom icon, or null for the default red marker

Link copied to clipboard
val id: String

The unique id of this marker, e.g. "m0", which stays the same for its lifetime. Useful as a key to find the marker again, e.g. in a listener. copy returns a marker with a new id.

Link copied to clipboard

The point of the icon the info window points at, as fractions of its width and height

Link copied to clipboard

Whether the icon lies flat on the map and turns with it, instead of facing the screen

Link copied to clipboard

Whether the info window is currently shown for this marker.

Link copied to clipboard

The geographic location of the marker, also changed while it is dragged

Link copied to clipboard

Clockwise rotation of the icon around the anchor in degrees, relative to the screen, or to north if isFlat

Link copied to clipboard

Snippet text shown below the title in the info window

Link copied to clipboard
var tag: Any?

Optional user data

Link copied to clipboard

Title text shown in the info window

Link copied to clipboard

Whether the marker is visible

Link copied to clipboard

Draw order: markers with a higher zIndex are drawn on top

Functions

Link copied to clipboard
fun copy(position: LatLng = this.position, title: String? = this.title, snippet: String? = this.snippet, icon: BitmapDescriptor? = this.icon, anchor: Pair<Float, Float> = this.anchor, infoWindowAnchor: Pair<Float, Float> = this.infoWindowAnchor, rotation: Float = this.rotation, isFlat: Boolean = this.isFlat, visible: Boolean = this.visible, alpha: Float = this.alpha, draggable: Boolean = this.draggable, zIndex: Float = this.zIndex, tag: Any? = this.tag): Marker

Returns a new marker with the given properties changed, not added to any map.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard

Hides the info window for this marker.

Link copied to clipboard
fun remove()

Removes the marker from the map that shows it, closing its info window.

Link copied to clipboard
fun setAnchor(anchorU: Float, anchorV: Float)

Sets the anchor from its two fractions, like setAnchor(float, float) of the Maps SDK.

Link copied to clipboard
fun setInfoWindowAnchor(anchorU: Float, anchorV: Float)

Sets the infoWindowAnchor from its two fractions, like setInfoWindowAnchor(float, float) of the Maps SDK.

Link copied to clipboard

Shows the info window for this marker.

Link copied to clipboard
open override fun toString(): String