A Vue 3 wrapper for the 2GIS MapGL library.
npm install mapgl-vueA Vue 3 wrapper for the 2GIS MapGL library.
``sh`
npm install mapgl-vue
First, install the plugin in your main Vue application file:
`typescript
import { createApp } from 'vue'
import App from './App.vue'
import { vueMapglPlugin } from 'mapgl-vue'
createApp(App)
.use(vueMapglPlugin)
.mount('#app')
`
See mini demo at https://stackblitz.com/edit/vitejs-vite-3zocdw?file=src%2Fmain.js
The library exports the following entities:
A Vue plugin that initializes the 2GIS MapGL library. It should be installed using app.use() as shown in the usage example above.
A composable function that provides access to the MapGL SDK. It returns an object with the following properties:
- loading: A computed ref indicating whether the SDK is still loading.sdk
- : A computed ref containing the MapGL SDK once it's loaded.onMapglReady
- : A function that takes a callback to be executed when the SDK is ready.
Example usage:
`vue`
A composable function for creating and managing a MapGL instance. It returns an object with the following method:
- createMap: A function that takes an HTML element (or its ID) and map options to create a new map instance.
Example usage:
`vue
`
A composable function for child components that need to interact with the map instance. It provides:
- onMapReady: A function that takes a callback to be executed when both the SDK and map instance are ready.
Example usage:
`vue``