---
title: "MapLibre GL JS · Nuxt Scripts"
description: "Add lazy-loaded, provider-agnostic vector maps to Nuxt with MapLibre GL JS."
canonical_url: "https://scripts.nuxt.com/scripts/maplibre"
meta:
  "og:description": "Add lazy-loaded, provider-agnostic vector maps to Nuxt with MapLibre GL JS."
  "og:image": "https://scripts.nuxt.com/_og/s/o_f6715cc40a127e37.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "MapLibre GL JS · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/s/o_f6715cc40a127e37.png"
---

> Index of every page on this site: [llms.txt](https://scripts.nuxt.com/llms.txt)

**Scripts**

# **MapLibre GL JS**

[Copy for LLMs](https://scripts.nuxt.com/scripts/maplibre.md)

[**MapLibre GL JS**](https://maplibre.org/maplibre-gl-js/docs/) is an open-source WebGL renderer for interactive vector maps. It renders the map and handles interaction; you choose the style, tile source, attribution, geocoding, and routing services separately.

Nuxt Scripts supports MapLibre GL JS v6 through the [`**useScriptMapLibre()**`](https://scripts.nuxt.com/scripts/maplibre/api/use-script-maplibre) composable and declarative components for common map resources. MapLibre v6 is ESM-only, so Nuxt Scripts loads it from the `**maplibre-gl**` package rather than a CDN script tag. The stylesheet comes from the same package.

`**injectStyles**``boolean` = true

Inject the MapLibre stylesheet when the script begins loading. Disable this when supplying the stylesheet through Nuxt.

`**stylesheetUrl**``string`

Stylesheet URL used when \`injectStyles\` is enabled. Defaults to the stylesheet shipped in the \`maplibre-gl\` package.

`**workerUrl**``string`

Worker URL passed to \`maplibregl.setWorkerUrl()\`. Set this when serving the MapLibre worker from your own origin.

## Setup

Install MapLibre v6, then enable the registry entry:

```bash
pnpm add -D maplibre-gl
```

nuxt.config.ts

```ts
export default defineNuxtConfig({
  scripts: {
    registry: {
      maplibre: { trigger: false },
    },
  },
})
```

## Quick Start

Pass a MapLibre style URL or an inline style specification. This example uses OpenFreeMap's keyless Liberty style.

```vue
<script setup lang="ts">
import type { LngLatLike } from 'maplibre-gl'

const center = ref<LngLatLike>([144.9631, -37.8136])
</script>

<template>
  <ScriptMapLibreMap
    v-model:center="center"
    map-style="https://tiles.openfreemap.org/styles/liberty"
    :zoom="12"
    width="100%"
    :height="480"
    aria-label="Map of central Melbourne"
  >
    <template #description>
      Interactive street map centred on Melbourne CBD.
    </template>

    <ScriptMapLibreNavigationControl position="top-right" />

    <ScriptMapLibreMarker
      :position="center"
      aria-label="Melbourne CBD"
    >
      <ScriptMapLibrePopup>
        Melbourne CBD
      </ScriptMapLibrePopup>
    </ScriptMapLibreMarker>
  </ScriptMapLibreMap>
</template>
```

MapLibre coordinates use `**[longitude, latitude]**` order. This is the reverse of the `**[latitude, longitude]**` convention used by Leaflet.

The default `**visible**` trigger defers the SDK, style, and tile requests until the map approaches the viewport. The component reserves its dimensions during SSR to avoid layout shift.

OpenFreeMap's public instance needs no API key, but it has no SLA. Read [**Styles & Providers**](https://scripts.nuxt.com/scripts/maplibre/guides/styles-and-providers) before choosing a production style service.

**Real-world example:** [**Build a delivery tracker**](https://scripts.nuxt.com/scripts/maplibre/guides/delivery-tracker) with reactive route progress, a live courier marker, error fallback content, and an accessible status alternative.

## Components

- [`**<ScriptMapLibreMap>**`](https://scripts.nuxt.com/scripts/maplibre/api/script-maplibre-map) creates the map and controls lazy loading.
- [`**<ScriptMapLibreMarker>**`](https://scripts.nuxt.com/scripts/maplibre/api/marker) adds an accessible, reactive marker.
- [`**<ScriptMapLibrePopup>**`](https://scripts.nuxt.com/scripts/maplibre/api/popup) binds slotted HTML to a marker or coordinate.
- [`**<ScriptMapLibreNavigationControl>**`](https://scripts.nuxt.com/scripts/maplibre/api/navigation-control) adds zoom, compass, and pitch controls.
- [`**<ScriptMapLibreScaleControl>**`](https://scripts.nuxt.com/scripts/maplibre/api/scale-control) adds a scale bar.
- [`**<ScriptMapLibreGeolocateControl>**`](https://scripts.nuxt.com/scripts/maplibre/api/geolocate-control) finds the user's location.
- [`**<ScriptMapLibreFullscreenControl>**`](https://scripts.nuxt.com/scripts/maplibre/api/fullscreen-control) toggles fullscreen mode.
- [`**<ScriptMapLibreAttributionControl>**`](https://scripts.nuxt.com/scripts/maplibre/api/attribution-control) moves or restyles the map attribution.
- [`**<ScriptMapLibreGeoJson>**`](https://scripts.nuxt.com/scripts/maplibre/api/geojson) manages a GeoJSON source and its style layers, including [**clustering**](https://scripts.nuxt.com/scripts/maplibre/api/geojson#clustering).

## Guides

- [**Delivery Tracker**](https://scripts.nuxt.com/scripts/maplibre/guides/delivery-tracker) builds a practical route tracker from reactive markers and styled GeoJSON.
- [**Styles & Providers**](https://scripts.nuxt.com/scripts/maplibre/guides/styles-and-providers) separates the renderer, style, tile service, and map data choices.
- [**Performance, CSP & Accessibility**](https://scripts.nuxt.com/scripts/maplibre/guides/performance-csp-and-accessibility) covers loading triggers, WebGL fallbacks, workers, and decorative maps.
- [**Raw Map Instance**](https://scripts.nuxt.com/scripts/maplibre/guides/raw-map-instance) covers layer events, filtering, feature state, and animated camera moves.

[Edit this page](https://github.com/nuxt/scripts/edit/main/docs/content/maplibre/index.md)

[Markdown For LLMs](https://scripts.nuxt.com/scripts/maplibre.md)

[**\<ScriptMapLibreFullscreenControl>** Adds MapLibre's fullscreen button to the nearest parent map. The map container goes fullscreen by default. Pass options.container to make a different element fullscreen.](https://scripts.nuxt.com/scripts/maplibre/api/fullscreen-control) [**Matomo Analytics** Track Matomo page views and events with built-in consent controls.](https://scripts.nuxt.com/scripts/matomo-analytics)

**On this page **

- [Setup](#setup)
- [Quick Start](#quick-start)
- [Components](#components)
- [Guides](#guides)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://scripts.nuxt.com/#website","@type":"WebSite","description":"Nuxt Scripts lets you load third-party scripts with better performance, privacy, security and DX. It includes many popular third-parties out of the box.","name":"Nuxt Scripts","url":"https://scripts.nuxt.com/","publisher":{"@id":"https://scripts.nuxt.com/#identity"}},{"@id":"https://scripts.nuxt.com/scripts/maplibre#webpage","@type":"WebPage","description":"Add lazy-loaded, provider-agnostic vector maps to Nuxt with MapLibre GL JS.","name":"MapLibre GL JS","url":"https://scripts.nuxt.com/scripts/maplibre","breadcrumb":{"@id":"https://scripts.nuxt.com/scripts/maplibre#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/scripts/maplibre"]}],"primaryImageOfPage":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/#identity","@type":"Organization","name":"Nuxt Scripts","url":"https://scripts.nuxt.com","logo":{"@id":"https://scripts.nuxt.com/#logo"}},{"@id":"https://scripts.nuxt.com/scripts/maplibre#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Nuxt Scripts","item":"https://scripts.nuxt.com/","position":1},{"@type":"ListItem","name":"Scripts","item":"https://scripts.nuxt.com/scripts","position":2},{"@type":"ListItem","name":"MapLibre GL JS","item":"https://scripts.nuxt.com/scripts/maplibre","position":3}]},{"@id":"https://scripts.nuxt.com/#logo","@type":"ImageObject","caption":"Nuxt Scripts","contentUrl":"https://scripts.nuxt.com/logo.svg","inLanguage":"en","url":"https://scripts.nuxt.com/logo.svg"}]}
```

## Sitemap

See the full [sitemap](https://scripts.nuxt.com/sitemap.md) for all pages.
