ym.modules.provider.Marker
Overview
Used to set markers on the map.
Initialization
Factory: ym.layerGroup(latlng, options)
Instantiates a marker object with a geographical point and optionally with further settings.
Parameter | Description | Data type | Default value |
---|---|---|---|
latlng | [erforderlich] | LatLng | |
options | [optional] | Marker-Options |
Parameter: options
Name | Description | Data type | Default value |
---|---|---|---|
icon | Icon class to be used for rendering the marker | Icon | |
clickable | If false, no mouse events are sent. The marker then acts as a part of the underlying map. | bool | true |
draggable | Indicates whether the marker can be moved by mouse or touch. | bool | false |
keyboard | Indicates whether the marker can be selected with the keyboard and clicked with the Enter key. | bool | true |
title | Text for the browser tooltip that is displayed during the hover event (default: no tooltip) | string | Leere Zeichenfolge |
alt | Text for the alt attribute of the icon image (useful for accessibility). | string | Leere Zeichenfolge |
zIndexOffset | By default, z-Index is automatically set for the marker image based on its width. Use this option if you want to place the marker above or below all others. Specify a high value like 1000 (or a high negative value). | int | 0 |
opacity | The opacity of the marker. | double | 1.0 |
riseOnHover | If true, the marker is placed over the others while you move the mouse over it. | bool | false |
riseOffset | The z-index offset used for the riseOnHover function. | int | 250 |
Events
Event | Event object | Description |
---|---|---|
add | Event | Is triggered when the marker is added to the map. |
click | MouseEvent | Is triggered when the user clicks (or taps) on the marker. |
contextmenu | MouseEvent | Is triggered when the user right-clicks on the marker. |
dblclick | MouseEvent | Is triggered when the user double-clicks (or double-taps) on the marker. |
drag | Event | Is triggered repeatedly while the user pulls the marker. |
dragend | DragEndEvent | Is triggered when the user stops dragging the marker. |
dragstart | Event | Is triggered when the user starts to drag the marker. |
mousedown | MouseEvent | Is triggered when the user presses the mouse button on the marker. |
mouseout | MouseEvent | Is triggered when the mouse leaves the selection. |
mouseover | MouseEvent | Is triggered when the mouse enters the marker. |
move | Event | Is triggered when the marker is moved via setLatLng. New coordinates are added to event arguments. |
popupclose | PopupEvent | Is triggered when a popup bound to the marker is closed. |
popupopen | PopupEvent | Is triggered when a popup bound to the marker is opened. |
remove | Event | Is triggered when the marker is removed from the map. |
Methods
addTo(map)
Adds a marker to the map.
Parameter | Description | Data type | Default value |
---|---|---|---|
map | Map |
- Return: this
getLatLng()
Returns the current geographic position of the marker.
- Return: LatLng
setLatLng(latlng)
Changes the position of the marker to the specified point.
Parameter | Description | Data type | Default value |
---|---|---|---|
latlng | LatLng |
- Return: this
setIcon(icon)
Changes the icon of the marker.
Parameter | Description | Data type | Default value |
---|---|---|---|
icon | Icon |
- Return: this
setZIndexOffset(offset)
Changes the z-index offset of the marker.
Parameter | Description | Data type | Default value |
---|---|---|---|
offset | int |
- Return: this
setOpacity(opacity)
Changes the opacity of the marker.
Parameter | Description | Data type | Default value |
---|---|---|---|
opacity | int |
- Return: this
update()
Updates the position of the marker (helpful if the coordinates of the corresponding latLng object were changed directly).
- Return: this
bindPopup(html, options)
Binds a popup with a specific HTML content to a click on this marker. You can also open the bound popup with the openPopup method.
Parameter | Description | Data type | Default value |
---|---|---|---|
html | string or HTMLElement or Popup | ||
options | [optional] | Popup options |
- Return: this
unbindPopup()
Removes the popup previously bound to the marker with bindPopup.
- Return: this
openPopup()
Opens the popup previously bound by the bindPopup method.
- Return: this
getPopup()
Returns the popup that was previously bound by the bindPopup method.
- Return: Popup
closePopup()
Closes the bound marker popup when it is open.
- Return: this
togglePopup()
Turns the popup previously bound by the bindPopup method on and off.
- Return: this
setPopupContent(html)
Sets an HTML content of the popup of this marker.
Parameter | Description | Data type | Default value |
---|---|---|---|
html | string or HTMLElement |
- Return: this
toGeoJSON()
Returns a GeoJSON representation of the marker (GeoJSON Point Feature).
- Return: Object