Getting Started
Get started with v-maplibre in your Vue 3 or Nuxt project
Installation
Only two packages are required. @geoql/v-maplibre keeps the install lean — deck.gl, raster, wind, LiDAR, and starfield support are all opt-in. See Optional Packages below.
Install the library and its single peer dependency:
pnpm add @geoql/v-maplibre maplibre-gl
That covers VMap, VMarker, VPopup, all controls (VControl*), and every MapLibre-native layer (VLayerMaplibre*).
Import Styles
Import the required CSS files in your main application file or component:
// main.ts or app.vue
import 'maplibre-gl/dist/maplibre-gl.css';
import '@geoql/v-maplibre/dist/v-maplibre.css';
MapLibre GL v6 Worker
MapLibre GL v6 computes its worker URL at runtime, next to its own module. In a bundled app that file does not exist, so the request gets a 404 and the map stays empty (#160).
VMap sets the worker URL for you. No setup needed.
The worker comes from your own maplibre-gl
This library ships no MapLibre worker code. It holds one reference, in the form MapLibre documents, and your bundler resolves it against the maplibre-gl your app installs:
new URL('maplibre-gl/dist/maplibre-gl-worker.mjs', import.meta.url);
Your build gets one worker file. So the worker and the map are always the same build. This matters: MapLibre passes typed arrays between the two threads as raw buffers, and their layout changes between releases. A 6.19.0 worker next to a 6.20.0 map throws Length of new data is N, which doesn't match current length of M, and the map never loads.
| Bundler | Result |
|---|---|
| Vite 8, Nuxt 4.5+ (dev and build) | The map loads. The worker is your maplibre-gl. |
| Vite 7 (dev and build) | The map loads. The worker is your maplibre-gl. |
| webpack 5, rspack | The map loads. The worker is your maplibre-gl. |
| No bundler (import map) | The map loads. MapLibre's own default is kept. |
| esbuild, Rollup without a URL plugin | Set the worker yourself (see below). |
maplibre-gl is a normal dependency with a caret range. You can upgrade maplibre-gl in your app at any time; no release of this library is needed.
A worker URL that you set before the first VMap mounts is kept. esbuild and Rollup do not resolve the references, so copy node_modules/maplibre-gl/dist/maplibre-gl-worker.mjs into your output and set it:
import { getVersion, setWorkerUrl } from 'maplibre-gl';
setWorkerUrl(
new URL(`./maplibre-gl-worker.mjs?v=${getVersion()}`, import.meta.url).href,
);
Your build output holds two worker files (about 550 kB each). The browser loads one of them.
CSP: the worker is a same-origin file, so worker-src 'self' is enough. blob: is only needed when the worker URL is on another origin.
Basic Usage
Here's a simple example to render a map:
<script setup lang="ts">
import { VMap } from '@geoql/v-maplibre';
import 'maplibre-gl/dist/maplibre-gl.css';
import '@geoql/v-maplibre/dist/v-maplibre.css';
const mapOptions = {
style: 'https://demotiles.maplibre.org/style.json',
center: [-74.5, 40],
zoom: 9,
};
</script>
<template>
<VMap :options="mapOptions" style="height: 500px"></VMap>
</template>
Nuxt Usage
For Nuxt applications, you need to configure the component to only render on the client side:
<script setup lang="ts">
import { VMap } from '@geoql/v-maplibre';
const mapOptions = {
style: 'https://demotiles.maplibre.org/style.json',
center: [-74.5, 40],
zoom: 9,
};
</script>
<template>
<ClientOnly>
<VMap :options="mapOptions" style="height: 500px"></VMap>
</ClientOnly>
</template>
Nuxt Global CSS (Recommended)
Add the styles to your nuxt.config.ts for global availability:
// nuxt.config.ts
export default defineNuxtConfig({
css: [
'maplibre-gl/dist/maplibre-gl.css',
'@geoql/v-maplibre/dist/v-maplibre.css',
],
});
Or use a Nuxt plugin:
// plugins/maplibre.client.ts
import 'maplibre-gl/dist/maplibre-gl.css';
import '@geoql/v-maplibre/dist/v-maplibre.css';
export default defineNuxtPlugin(() => {
// Plugin loaded
});
Optional Packages
Add these only for the layers you actually use. Each row's components stay tree-shaken out of your bundle until you import them:
| Feature | Components | Install |
|---|---|---|
| deck.gl base | VLayerDeckgl, VLayerDeckglScatterplot, VLayerDeckglArc, VLayerDeckglLine, VLayerDeckglPath, VLayerDeckglPolygon, VLayerDeckglSolidPolygon, VLayerDeckglGeojson, VLayerDeckglIcon, VLayerDeckglText, VLayerDeckglColumn, VLayerDeckglBitmap, VLayerDeckglPointCloud | pnpm add @deck.gl/core @deck.gl/layers @deck.gl/mapbox |
| Aggregation | VLayerDeckglHeatmap, VLayerDeckglHexagon, VLayerDeckglGrid, VLayerDeckglGridCell, VLayerDeckglContour, VLayerDeckglScreenGrid | pnpm add @deck.gl/aggregation-layers |
| Geo / tiles | VLayerDeckglTrips, VLayerDeckglMVT, VLayerDeckglTile, VLayerDeckglTile3D, VLayerDeckglTerrain, VLayerDeckglH3Hexagon, VLayerDeckglH3Cluster, VLayerDeckglS2, VLayerDeckglGeohash, VLayerDeckglQuadkey, VLayerDeckglGreatCircle, VLayerDeckglWMS | pnpm add @deck.gl/geo-layers |
| 3D mesh | VLayerDeckglSimpleMesh, VLayerDeckglScenegraph | pnpm add @deck.gl/mesh-layers |
| Raster (COG) | VLayerCog, VLayerMultiCog, VLayerMosaic | pnpm add @developmentseed/deck.gl-geotiff@^0.10 @developmentseed/deck.gl-raster@^0.10 @developmentseed/geotiff@^0.10 @developmentseed/proj@^0.10 |
| Zarr | VLayerZarr | pnpm add @developmentseed/deck.gl-zarr@^0.10 @developmentseed/deck.gl-raster@^0.10 @developmentseed/proj@^0.10 zarrita |
| GeoArrow | VLayerDeckglGeoArrowScatterplot, VLayerDeckglGeoArrowPath, VLayerDeckglGeoArrowPolygon, VLayerDeckglGeoArrowSolidPolygon, VLayerDeckglGeoArrowText, VLayerDeckglGeoArrowTrips | pnpm add @deck.gl/layers apache-arrow (+ @deck.gl/geo-layers for trips) |
| Wind particles | VLayerWindParticle | pnpm add maplibre-gl-wind |
| LiDAR | VControlLidar | pnpm add maplibre-gl-lidar |
| Starfield | VLayerStarfield | pnpm add @geoql/maplibre-gl-starfield three |
If you import a layer without its peer deps installed, your bundler will report Cannot find module '...' — install the missing package(s) from the row above to resolve it.