schlunsen/nuxt-leaflet

this.$L not available in composition API

digitalforgeangelo opened this issue · 1 comments

As the title says, how can I get to the $L when using composition API?
I need to get my mouse position i.e. coords.

In my plugin file, then add that file in nuxt.config

import Vue from 'vue'
import * as L from 'leaflet'
import Vue2LeafletMarkerCluster from 'vue2-leaflet-markercluster'
Vue.component('LCluster', Vue2LeafletMarkerCluster)

export default function (_context, inject) {
  const LeafletPlugin = Vue.prototype.$L
  inject('L', LeafletPlugin)
}

then inside my component

import { useContext } from '@nuxtjs/composition-api'

const { $L } = useContext()

then just access $L normally