---
title: "useScriptMapLibre · Nuxt Scripts"
description: "Use useScriptMapLibre() when you need direct access to the MapLibre namespace or are building your own map component."
canonical_url: "https://scripts.nuxt.com/scripts/maplibre/api/use-script-maplibre"
meta:
  "og:description": "Use useScriptMapLibre() when you need direct access to the MapLibre namespace or are building your own map component."
  "og:image": "https://scripts.nuxt.com/_og/s/o_efb3b6b8865cbf66.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "useScriptMapLibre · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/s/o_efb3b6b8865cbf66.png"
---

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

**Api**

# **useScriptMapLibre**

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

Use `**useScriptMapLibre()**` when you need direct access to the MapLibre namespace or are building your own map component.

```ts
const { onLoaded } = useScriptMapLibre()

onLoaded(({ maplibregl }) => {
  const bounds = new maplibregl.LngLatBounds(points)
  // Use the MapLibre API directly.
})
```

[Edit this page](https://github.com/nuxt/scripts/edit/main/docs/content/maplibre/2.api/6.use-script-maplibre.md)

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

[**\<ScriptMapLibreGeoJson>** Adds a GeoJSON source and one or more MapLibre style layers. Replacing data updates the existing source. A paint, layout or filter change updates the layers in place. A change to cluster, clusterRadius or clusterMaxZoom updates the source in place. Any other layer or source option change rebuilds the source and layers in a controlled order.](https://scripts.nuxt.com/scripts/maplibre/api/geojson) [**\<ScriptMapLibreScaleControl>** Adds MapLibre's scale bar to the nearest parent map. MapLibre places it in the bottom-left corner by default.](https://scripts.nuxt.com/scripts/maplibre/api/scale-control)

```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/api/use-script-maplibre#webpage","@type":"WebPage","description":"Use useScriptMapLibre() when you need direct access to the MapLibre namespace or are building your own map component.","name":"useScriptMapLibre","url":"https://scripts.nuxt.com/scripts/maplibre/api/use-script-maplibre","breadcrumb":{"@id":"https://scripts.nuxt.com/scripts/maplibre/api/use-script-maplibre#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/scripts/maplibre/api/use-script-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/api/use-script-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","item":"https://scripts.nuxt.com/scripts/maplibre","position":3},{"@type":"ListItem","name":"API","item":"https://scripts.nuxt.com/scripts/maplibre/api","position":4},{"@type":"ListItem","name":"useScriptMapLibre","item":"https://scripts.nuxt.com/scripts/maplibre/api/use-script-maplibre","position":5}]},{"@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.
