Skip to content

🧩 LMap ​

Base component, contains and wraps all the other components.

πŸ§ͺ Demo ​

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

const zoom = ref<number>(2)
</script>

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

βš™οΈ Props ​

Prop nameDescriptionTypeReactiveDefaultRequired
widthThe width of the mapstringtrue-false
heightThe height of the mapstringtrue-false
centerThe center of the map, supports v-modelPointExpressiontrue-false
boundsThe bounds of the map, supports v-modelLatLngBoundstrue-false
maxBoundsThe max bounds of the mapLatLngBoundstrue-false
zoomThe zoom of the map, supports v-modelnumbertrue-false
minZoomThe minZoom of the mapnumbertrue-false
maxZoomThe maxZoom of the mapnumbertrue-false
paddingBottomRightThe paddingBottomRight of the map. Applies only when LMap.fitBounds is called.PointExpressiontrue-false
paddingTopLeftThe paddingTopLeft of the map. Applies only when LMap.fitBounds is called.PointExpressiontrue-false
paddingThe padding of the map. Applies only when LMap.fitBounds is called.PointExpressiontrue-false
worldCopyJumpWith this option enabled, the map tracks when you pan to another "copy" of the world and seamlessly jumps to the original one so that all overlays like markers and vector layers are still visible.booleaninitOnly-false
crsThe Coordinate Reference System to use. Don't change this if you're not sure what it means.CRS | TSTypeQuerytrue-false
maxBoundsViscosityIf maxBounds is set, this option will control how solid the bounds are when dragging the map around. The default value of 0.0 allows the user to drag outside the bounds at normal speed, higher values will slow down map dragging outside bounds, and 1.0 makes the bounds fully solid, preventing the user from dragging outside the bounds.numberinitOnly-false
inertiaIf enabled, panning of the map will have an inertia effect where the map builds momentum while dragging and continues moving in the same direction for some time. Feels especially nice on touch devices. Enabled by default.booleaninitOnly-false
inertiaDecelerationThe rate with which the inertial movement slows down, in pixels/secondΒ².numberinitOnly-false
inertiaMaxSpeedMax speed of the inertial movement, in pixels/second.numberinitOnly-false
easeLinearityThe curvature factor of panning animation easing (third parameter of the Cubic Bezier curve). 1.0 means linear animation, and the smaller this number, the more bowed the curve.numberinitOnly-false
zoomAnimationWhether the map zoom animation is enabled. By default it's enabled in all browsers that support CSS3 Transitions except Android.booleaninitOnly-false
zoomAnimationThresholdWon't animate zoom if the zoom difference exceeds this value.numberinitOnly-false
fadeAnimationWhether the tile fade animation is enabled. By default it's enabled in all browsers that support CSS3 Transitions except Android.booleaninitOnly-false
markerZoomAnimationWhether markers animate their zoom with the zoom animation, if disabled they will disappear for the length of the animation. By default, it's enabled in all browsers that support CSS3 Transitions except Android.booleaninitOnly-false
noBlockingAnimationsWhether blocking animations are allowed or not (primarily for ZoomPanOptions ?booleaninitOnly-false
beforeMapMount-TSFunctionTypeinitOnly-false

πŸ”— Inherited props ​

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

πŸ“‘ Emits ​

EventArgumentsDescription
readyMapTriggers when the component is ready
update:zoomnumberTriggers when the map's zoom level changes.
update:centerLatLngTriggers when the map's center coordinates are updated.
update:boundsLatLngBoundsTriggers when the map's visible bounds are updated.

🎯 Slots ​

NameDescription
defaultThe default slot is rendered inside the map container and is used to embed layer components, controls, or any custom Vue components. Common usage includes placing LTileLayer, LMarker, LPopup, LFeatureGroup, or other Leaflet-related elements that interact with the map.

🧭 Exposes ​

NameTypeDescription
rootRef<HTMLElement | undefined>The root DOM element of the Leaflet map. This element is used to create the Leaflet's Map class. You can use it to directly manipulate the map's container (e.g. styling, event listeners).
readyRef<boolean>Indicates whether the component and its underlying Leaflet object are fully initialized.
leafletObjectRef<Map | undefined>The underlying Leaflet instance. Can be used to directly interact with the Leaflet API (e.g. calling methods or accessing internal state).
attrs--