Skip to content

๐Ÿงฉ LControl โ€‹

Base component for implementing map controls. Handles positioning. All other controls extend from this component.

๐Ÿงช Demo โ€‹

vue
<script setup>
import { LMap, LTileLayer, LControl } from '@maxel01/vue-leaflet'

const clickHandler = () => {
    alert('and mischievous')
}
</script>

<template>
    <LMap :zoom="8" :center="[47.21322, -1.559482]">
        <LTileLayer
            url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
            attribution="&amp;copy; <a href=&quot;https://www.openstreetmap.org/&quot;>OpenStreetMap</a> contributors"
            layer-type="base"
            name="OpenStreetMap"
        />
        <LControl position="bottomleft">
            <button
                style="background: white; color: black; padding: 2px; border-radius: 5px;"
                @click="clickHandler"
            >I am a useless button!
            </button>
        </LControl>
    </LMap>
</template>

โš™๏ธ Props โ€‹

Prop nameDescriptionTypeReactiveDefaultRequired
disableClickPropagationAdds stopPropagation to the element's click, dblclick, contextmenu and pointerdown events (plus browser variants).booleaninitOnly-false
disableScrollPropagationAdds stopPropagation to the element's wheel events (plus browser variants).booleaninitOnly-false
------------------
positionThe position of the control (one of the map corners). Possible values are topleft, topright, bottomleft or bottomright.ControlPositiontrue-false

๐Ÿ”— Inherited props โ€‹

from ComponentProps
Prop nameDescriptionTypeReactiveDefaultRequired
optionsLeaflet options to pass to the component constructor.TinitOnly-false

๐Ÿ“ก Emits โ€‹

EventArgumentsDescription
readyTTriggers when the component is ready

๐ŸŽฏ Slots โ€‹

NameDescription
defaultContent to be rendered inside the Leaflet control's container. This slot replaces the default content and allows full customization of the control's appearance. The content will be injected into the control's root DOM element.

๐Ÿงญ Exposes โ€‹

NameTypeDescription
rootRef<HTMLElement | undefined>The root DOM element of the Leaflet control. This element is managed by Leaflet's Control class. You can use it to directly manipulate the control's container (e.g. styling, event listeners), or alternatively use the default slot for custom content.
leafletObjectRef<Control | undefined>The underlying Leaflet instance. Can be used to directly interact with the Leaflet API (e.g. calling methods or accessing internal state).