Skip to content

๐Ÿงฉ LPolygon โ€‹

Easily draw a polygon on the map

๐Ÿงช Demo โ€‹

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

<template>
    <LMap :zoom="4" :center="[24.886, -70.268]">
        <LTileLayer
            url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
            layer-type="base"
            name="OpenStreetMap"
        />
        <LPolygon
            :lat-lngs="[
                [25.774, -80.19],
                [18.466, -66.118],
                [32.321, -64.757],
                [25.774, -80.19]
            ]"
            color="#41b782"
            :fill="true"
            :fillOpacity="0.5"
            fillColor="#41b782"
        />
    </LMap>
</template>

โš™๏ธ Props โ€‹

Prop nameDescriptionTypeReactiveDefaultRequired
latLngsArray of coordinates objects that represent the polyline.Arraytrue-true

๐Ÿ”— Inherited props โ€‹

from PolylineAbstractProps
Prop nameDescriptionTypeReactiveDefaultRequired
smoothFactorHow much to simplify the polyline on each zoom level. More means better performance and smoother looks, and less means more accurate representation.numbertrue-false
noClipDisable polyline clipping.booleantrue-false
from PathProps
Prop nameDescriptionTypeReactiveDefaultRequired
classNameCustom class name set on an element. Only for SVG renderer.stringtrue-false
fillRuleA string that defines how the inside of a shape is determined.FillRuletrue-false
fillOpacityFill opacitynumbertrue-false
fillColorFill colorstringtrue-false
fillWhether to fill the path with color. Set it to false to disable filling on polygons or circles.booleantrue-false
dashOffsetA string that defines the distance into the dash pattern to start the dash.stringtrue-false
dashArrayA string that defines the stroke dash pattern.stringtrue-false
lineJoinA string that defines shape to be used at the corners of the stroke.LineJoinShapetrue-false
lineCapA string that defines shape to be used at the end of the stroke.LineCapShapetrue-false
opacityStroke opacitynumbertrue-false
weightStroke width in pixelsnumbertrue-false
colorStroke colorstringtrue-false
strokeWhether to draw stroke along the path. Set it to false to disable borders on polygons or circles.booleantrue-false
from InteractiveLayerProps
Prop nameDescriptionTypeReactiveDefaultRequired
interactiveIf false, the layer will not emit pointer events and will act as a part of the underlying map.booleaninitOnly-false
bubblingMouseEventsWhen true, a pointer event on this path will trigger the same event on the map (unless DomEvent.stopPropagation is used).booleaninitOnly-false
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
readyTTriggers when the component is ready

๐ŸŽฏ Slots โ€‹

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

๐Ÿงญ Exposes โ€‹

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