This helper Package uses vue2-leaflet. Please check the vue2-leaflet Docs for more Infos.
- Install Module via
yarn add leaflet-nuxt-async
- Require Module in main file
import 'leaflet-nuxt-async';
In nuxt.config.js add
{
modules: [
'leaflet-nuxt-async/nuxt'
]
}
// Import on Top:
const matcherLeaflet = require('leaflet-nuxt-async/vuetifyLoader')
match(_originalTag, { camelTag }) {
const checkLeaflet = matcherLeaflet(camelTag)
if (checkLeaflet) {
return checkLeaflet
}
}
You can use this module with vuetify loader also without nuxt. But process.client
has to be true only on client and not while SSR.
You should wrap your maps in <no-ssr>
or <client-only>
when useing SSR.
With this Module all Components from vue2-leaflet get registerd as async components with codesspliting in webpack.
Just use import * as L from 'leaflet'
in normal Vue.
let L = null;
if(process.client) {
L = require('leaflet');
}
// Use L witch check for null (for example with Babel or Typescript useing L?.Icon?.default)
In Nuxt you can savely use require('leaflet')
in methods and in the mounted hoock.
This Package is build with Treeshaking in Mind so not used Components are in extra chunks or removed. For leaflet consider useing our Fork EC-Nordbund/leaflet for treeshaking leaflet.