---
title: "<ScriptMapLibreMap> · Nuxt Scripts"
description: "The map facade reserves layout space during SSR, loads MapLibre when triggered, creates the Map, and provides it to child components."
canonical_url: "https://scripts.nuxt.com/scripts/maplibre/api/script-maplibre-map"
meta:
  "og:description": "The map facade reserves layout space during SSR, loads MapLibre when triggered, creates the Map, and provides it to child components."
  "og:image": "https://scripts.nuxt.com/_og/s/o_5a320489b317202e.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "<ScriptMapLibreMap> · Nuxt Scripts"
  "twitter:image": "https://scripts.nuxt.com/_og/s/o_5a320489b317202e.png"
---

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

**Api**

# **\<ScriptMapLibreMap>**

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

The map facade reserves layout space during SSR, loads MapLibre when triggered, creates the `**Map**`, and provides it to child components.

`**trigger**``ElementScriptTrigger` = 'visible'

Defines when the MapLibre script loads.

`**mapStyle**``string | MapLibre.StyleSpecification`** required **

`**center**``MapLibre.LngLatLike`** required **

`**zoom**``number`

`**bearing**``number`

`**pitch**``number`

`**options**``Omit<MapLibre.MapOptions, 'container'>`

`**injectStyles**``boolean`

`**stylesheetUrl**``string`

`**workerUrl**``string`

`**width**``number | string`

`**height**``number | string`

`**ariaLabel**``string`

`**interactive**``boolean`

`**rootAttrs**``HTMLAttributes & ReservedProps & Record<string, unknown>`

`**mapStyle**`, `**center**`, `**zoom**`, `**bearing**`, `**pitch**`, and `**bounds**` are reactive.

`**center**`, `**zoom**`, `**bearing**`, and `**pitch**` also take a `**v-model**` binding. Use it when you also want to receive camera changes made by the user.

`**bounds**` is one-way reactive. The map fits a new area, and it does not report a user pan or zoom back to you.

```vue
<ScriptMapLibreMap
  v-model:center="center"
  v-model:zoom="zoom"
  v-model:bearing="bearing"
  map-style="https://demotiles.maplibre.org/style.json"
  width="100%"
  height="28rem"
  @ready="({ map }) => console.log(map.value)"
>
  <template #description>
    A street map with one marker at the selected office.
  </template>
</ScriptMapLibreMap>
```

## Frame the Data

Set `**bounds**` to fit the first camera to an area. `**bounds**` takes `**[[west, south], [east, north]]**` or `**[west, south, east, north]**`. If you set `**bounds**`, `**center**` is optional. The map type rejects a map with neither `**center**` nor `**bounds**`.

```vue
<ScriptMapLibreMap
  map-style="https://tiles.openfreemap.org/styles/liberty"
  :bounds="[[144.94, -37.83], [144.97, -37.81]]"
  :fit-bounds-options="{ padding: 48, maxZoom: 15 }"
  width="100%"
  :height="480"
/>
```

`**fitBoundsOptions**` takes MapLibre's [`**FitBoundsOptions**`](https://maplibre.org/maplibre-gl-js/docs/API/type-aliases/FitBoundsOptions/). Use `**padding**` to keep features away from the edge. Use `**maxZoom**` to stop a single point from zooming in too far.

### Precedence

- If you set `**center**` and `**bounds**`, `**bounds**` sets the initial center and zoom. `**center**` and `**zoom**` apply only when they change later.
- The fit keeps the `**bearing**` prop. MapLibre's own fit resets the bearing to 0. To change the bearing during the fit, set `**bearing**` in `**fitBoundsOptions**`.
- `**pitch**` applies as usual.

### Later Changes

- If the `**bounds**` coordinates change, the map fits the new area. The fit jumps without animation, like the other camera props.
- If `**bounds**` gets a new array with the same coordinates, the camera stays where it is. A parent render cannot undo a pan or zoom by the user.
- A change to `**fitBoundsOptions**` alone does not fit again. The next `**bounds**` change uses the new options.
- If you remove `**bounds**`, the camera stays where it is. If you set the same coordinates again later, the map fits them again.

For an animated fit, call `**fitBounds**` from the `**ready**` payload or a template ref.

The `**placeholder**`, `**awaitingLoad**`, `**loading**`, and `**error**` slots customize each loading state. The default error state is visible and announced with `**role="alert"**`.

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

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

[**Raw Map Instance** Call the MapLibre Map directly for layer events, filtering, hover state, and camera animation.](https://scripts.nuxt.com/scripts/maplibre/guides/raw-map-instance) [**\<ScriptMapLibreAttributionControl>** Moves or restyles the map's attribution. Use it to change the attribution position, force compact mode, or add your own credits.](https://scripts.nuxt.com/scripts/maplibre/api/attribution-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/script-maplibre-map#webpage","@type":"WebPage","description":"The map facade reserves layout space during SSR, loads MapLibre when triggered, creates the Map, and provides it to child components.","name":"<ScriptMapLibreMap>","url":"https://scripts.nuxt.com/scripts/maplibre/api/script-maplibre-map","breadcrumb":{"@id":"https://scripts.nuxt.com/scripts/maplibre/api/script-maplibre-map#breadcrumb"},"isPartOf":{"@id":"https://scripts.nuxt.com/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://scripts.nuxt.com/scripts/maplibre/api/script-maplibre-map"]}],"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/script-maplibre-map#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":"<ScriptMapLibreMap>","item":"https://scripts.nuxt.com/scripts/maplibre/api/script-maplibre-map","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.
