Vue-MapLibre-GL is a small, actively maintained Vue 3 plugin that provides components and utilities for integrating MapLibre GL JS into Vue applications. The current stable version is 5.6.1, with minor releases occurring frequently, indicating active development and responsiveness to bug fixes and feature enhancements. Key differentiators include full TypeScript support, a comprehensive set of Vue components for managing maps, controls, sources, markers, and layers, and a built-in 'Simple Draw Control' that allows users to draw polygons, circles, and static circles. It also features support for multiple map instances via the `useMap` composition API hook, customizable style switching, language toggling, and automatic map restart on `CONTEXT_LOST_WEBGL` events, which is particularly useful for mobile device stability.
npm install vue-maplibre-glVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up a basic MapLibre GL map within a Vue 3 application, including a navigation control. It shows the necessary imports for CSS and Vue components, and initializes the map with a default style and view.
Manually install required Turf.js modules, e.g., `npm install @turf/turf` or specific `@turf/*` packages if you only need certain functionalities.
Add `@use '~vue-maplibre-gl/dist/vue-maplibre-gl-draw.css';` to your CSS or `import 'vue-maplibre-gl/dist/vue-maplibre-gl-draw.css';` in your JavaScript entry point.
Always check the `maplibre-gl` changelog for breaking changes when updating. Ensure your `maplibre-gl` peer dependency range is conservative (e.g., `^5.0.0`) to prevent automatic major version upgrades without review. Test your application thoroughly after any `maplibre-gl` update.
Account for potential map reloads in your application state management, especially if you store map-related settings (e.g., drawn features, current view) that might need to be reapplied after a context loss and restart.
Install the `maplibre-gl` package: `npm install maplibre-gl` or `yarn add maplibre-gl`.
Ensure `import { MglMap } from 'vue-maplibre-gl'` is present and `MglMap` is listed in the `components` object of your Vue component, or perform a global installation using `app.use(VueMaplibreGl)` in your main.js/ts file.Ensure controls are instantiated and added within the context of an `MglMap` component or its `map` instance, typically after the map `load` event. Use `Mgl*Control` components provided by `vue-maplibre-gl` for easier integration.