← All components
GeoJSON layer
Declare a source and layer in JSX. It survives style changes.
Previews run on MapScale's public Thailand archive.
Install
npx shadcn@latest add https://mapscale.io/r/geojson-layer.jsonUsage
import { GeoJSONLayer } from "@/components/mapscale/geojson-layer"
<Map>
<GeoJSONLayer
id="zones"
type="fill"
data={zones}
paint={{ "fill-color": "#2563eb", "fill-opacity": 0.25 }}
/>
</Map>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| id | string | - | Used as both the source id and the layer id. |
| data | GeoJSON | string | - | GeoJSON object or URL. Updated in place when it changes. |
| type | string | - | fill, line, circle, symbol, heatmap or fill-extrusion. |
| paint | object | {} | MapLibre paint properties. Changes apply without re-adding the layer. |
| layout | object | {} | MapLibre layout properties. |
| beforeId | string | - | Insert the layer below this existing layer. |
Keys
Maps, autocomplete and place details use a publishable pk_ key that is safe in the browser. Routing and isochrones need a secret sk_ key, so they go through the proxy route your app serves.