Skip to content

๐Ÿงฉ LMarker โ€‹

Used to display clickable/draggable markers on the map.

๐Ÿงช Demo โ€‹

vue
<script setup lang="ts">
import { LMap, LMarker, LTileLayer } from '@maxel01/vue-leaflet'
import type { LatLngTuple } from 'leaflet'

const coordinates: LatLngTuple = [50, 50]
</script>

<template>
    <LMap :zoom="2" :center="[47.41322, -1.219482]">
        <LTileLayer
            url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
            layer-type="base"
            name="OpenStreetMap"
        />
        <LMarker :lat-lng="coordinates" draggable />
    </LMap>
</template>

โš™๏ธ Props โ€‹

Prop nameDescriptionTypeReactiveDefaultRequired
draggableWhether the marker is draggable with mouse/touch or not.booleantrue-false
iconIcon instance to use for rendering the marker. See Icon documentation for details on how to customize the marker icon. If not specified, a common instance of Icon.Default is used.Icontrue-false
zIndexOffsetBy default, marker images zIndex is set automatically based on its latitude. Use this option if you want to put the marker on top of all others (or below), specifying a high value like 1000 (or high negative value, respectively).numbertrue-false
latLngThe position of the markerLatLngExpressiontrue-true

๐Ÿ”— Inherited props โ€‹

from LayerProps
Prop nameDescriptionTypeReactiveDefaultRequired
visible-booleantrue-false
layerType-LayerTypetrue-false
name-stringtrue-false
attributionString to be shown in the attribution control, e.g. "ยฉ OpenStreetMap contributors". It describes the layer data and is often a legal obligation towards copyright holders and tile providers.stringtrue-false
paneBy default, the layer will be added to the map's overlay pane. Overriding this option will cause the layer to be placed on another pane by default. Not effective if the renderer option is set (the renderer option will override the pane option).stringinitOnly-false
from ComponentProps
Prop nameDescriptionTypeReactiveDefaultRequired
optionsLeaflet options to pass to the component constructor.TinitOnly-false

๐Ÿ“ก Emits โ€‹

EventArgumentsDescription
update:visiblebooleanTriggers when the visible prop needs to be updated
readyMarkerTriggers when the component is ready
update:latLngLatLngExpressionTriggers when the latLng prop needs to be updated
update:lat-lngLatLngExpressionTriggers when the latLng prop needs to be updated

๐ŸŽฏ Slots โ€‹

NameDescription
defaultUsed to inject Leaflet child components like <LPopup> or <LTooltip> into the LMarker.

๐Ÿงญ Exposes โ€‹

NameTypeDescription
readyRef<boolean>Indicates whether the component and its underlying Leaflet object are fully initialized.
leafletObjectRef<Marker | undefined>The underlying Leaflet instance. Can be used to directly interact with the Leaflet API (e.g. calling methods or accessing internal state).