---
title: "<ScriptMapLibreGeoJson>"
description: "Adds a GeoJSON source and one or more MapLibre style layers. Replacing data updates the existing source; changing layer or source options rebuilds resources in a controlled order."
canonical_url: "https://scripts.nuxt.com/scripts/maplibre/api/geojson"
last_updated: "2026-08-11T04:27:01.955Z"
---

Adds a GeoJSON source and one or more MapLibre style layers. Replacing `data` updates the existing source; changing layer or source options rebuilds resources in a controlled order.

Changing `source-id` removes the previously owned source and layers before recreating them under the new ID.

<script-types filter="ScriptMapLibreGeoJson" script-key="maplibre">



</script-types>

Each layer gets the component's `source-id` unless it explicitly supplies another source. The component also restores its source and layers after the map style changes.

Remote fetching is intentionally outside the component. Fetch and validate data with `useFetch`, then pass the resulting object to `data` so loading and failure states remain explicit.
