
Security News
Software Engineering Daily Podcast: Feross on AI, Open Source, and Supply Chain Risk
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.
@vue-leaflet/vue-leaflet
Advanced tools
Vue-leaflet, written and compatible with Vue 3!
This is a Beta version! And may yet be unstable! If you want to help, please reach out in an issue or on discord, or join the discussions.
Note that unlike the Vue 2 version, this library is fully compatible with SSR.
yarn add @vue-leaflet/vue-leaflet leaflet
or
npm i -D @vue-leaflet/vue-leaflet leaflet
Until the complete documentation is ready, please check the component playground examples or the demo project for usage with Vue 3. Most component props mimic the vanilla Leaflet options as closely as possible, and generally remain the same as in their Vue2Leaflet counterparts.
<template>
<div style="height:600px; width:800px">
<l-map ref="map" v-model:zoom="zoom" :center="[47.41322, -1.219482]">
<l-tile-layer
url="https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"
layer-type="base"
name="OpenStreetMap"
></l-tile-layer>
</l-map>
</div>
</template>
<script>
import "leaflet/dist/leaflet.css";
import { LMap, LTileLayer } from "@vue-leaflet/vue-leaflet";
export default {
components: {
LMap,
LTileLayer,
},
data() {
return {
zoom: 2,
};
},
};
</script>
<style></style>
To see the component playground in action, clone this repo and run the local devserver, then visit http://127.0.0.1:5173,
git clone https://github.com/vue-leaflet/vue-leaflet.git
cd vue-leaflet
yarn
yarn dev
Note that while the vue-leaflet library has the option of enabling SSR, Leaflet itself does not.
N.B. Using
import L from "leaflet"orimport { ... } from "leaflet"can lead to unexpected errors.
To provide server-side rendering and tree-shaking capabilities, vue-leaflet can be configured to use async imports from the
Leaflet ESM, by disabling the useGlobalLeaflet option on the map component, <l-map :useGlobalLeaflet="false">.
This can lead to issues when importing additional methods from Leaflet, because the two instances of the Leaflet classes are technically no longer the same. See Issue 48 for more.
To avoid these issues, import any Leaflet methods asynchronously in response to the LMap component's @ready event:
<template>
<div style="height:600px; width:800px">
<p>vue-leaflet SSR Demo</p>
<l-map :useGlobalLeaflet="false">
<l-geo-json :geojson="geojson" :options="geojsonOptions" />
</l-map>
</div>
</template>
<script>
// DON'T load Leaflet components here!
// Its CSS is needed though, if not imported elsewhere in your application.
import "leaflet/dist/leaflet.css"
import { LMap, LGeoJson } from "@vue-leaflet/vue-leaflet";
export default {
components: {
LMap,
LGeoJson,
},
data() {
return {
geojson: {
type: "FeatureCollection",
features: [
// ...
],
},
geojsonOptions: {
// Options that don't rely on Leaflet methods.
},
};
},
async beforeMount() {
// HERE is where to load Leaflet components!
const { circleMarker } = await import("leaflet/dist/leaflet-src.esm");
// And now the Leaflet circleMarker function can be used by the options:
this.geojsonOptions.pointToLayer = (feature, latLng) =>
circleMarker(latLng, { radius: 8 });
this.mapIsReady = true;
},
};
</script>
[0.10.1] - 2023-06-16
FAQs
Vue-leaflet, written and compatible with Vue 3!
We found that @vue-leaflet/vue-leaflet demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.

Security News
GitHub has revoked npm classic tokens for publishing; maintainers must migrate, but OpenJS warns OIDC trusted publishing still has risky gaps for critical projects.

Security News
Rust’s crates.io team is advancing an RFC to add a Security tab that surfaces RustSec vulnerability and unsoundness advisories directly on crate pages.