Nuxt module for leafletjs
Nuxt module for vue2-leaflet.
See vue2-leaflet for more details.
- Add
@zeraton/nuxt-leaflet
dependency using yarn or npm to your project - Add
@zeraton/nuxt-leaflet
tomodules
section ofnuxt.config.js
{
modules: [
// Simple usage
'@zeraton/nuxt-leaflet',
// With options
['@zeraton/nuxt-leaflet', { /* module options */ }],
]
}
Add the map to your page
<div id="map-wrap" style="height: 100vh">
<no-ssr>
<l-map :zoom=13 :center="[55.9464418,8.1277591]">
<l-tile-layer url="http://{s}.tile.osm.org/{z}/{x}/{y}.png"></l-tile-layer>
<l-marker :lat-lng="[55.9464418,8.1277591]"></l-marker>
</l-map>
</no-ssr>
</div>
The Leaflet 'L' object can be found on vue component: this.$L
If you're using TypeScript, you'll need to add nuxt-leaflet in your compilerOptions of your tsconfig.json :
{
"compilerOptions": {
"types": [
"@types/node",
"@nuxt/vue-app",
"@zeraton/nuxt-leaflet"
]
}
}
You'll then be able to have autocompletion in Vue instances (this.$L
).
See components supported
- Clone this repository
- Install dependencies using
yarn install
ornpm install
- Start development server using
npm run dev
Copyright (c) Zeraton GmbH (c) Rasmus Schlunsen