Skip to content

RootSchema

const RootSchema: z.ZodType<any>

Defined in: packages/core/src/schemas/page.schema.ts:455

Root configuration schema.

The root schema represents the entire maplibre-yaml configuration. This is the top-level structure for YAML files.

Structure:

  1. config - Global settings (optional)
  2. layers - Named layer definitions for reuse (optional)
  3. sources - Named source definitions for reuse (optional)
  4. pages - Page definitions (required, minimum 1)

Global Layers and Sources: Define layers and sources once, reference them anywhere using $ref.

Minimal Configuration

pages:
- path: "/"
title: "Home"
blocks:
- type: map
id: main-map
config:
center: [0, 0]
zoom: 2
mapStyle: "https://demotiles.maplibre.org/style.json"

With Global Config

config:
title: "My App"
defaultMapStyle: "https://demotiles.maplibre.org/style.json"
pages:
- path: "/"
title: "Home"
blocks:
- type: map
id: main-map
config:
center: [0, 0]
zoom: 2

With Global Layers

config:
defaultMapStyle: "https://demotiles.maplibre.org/style.json"
layers:
bikeLayer:
id: bikes
type: line
source:
type: geojson
url: "https://example.com/bikes.geojson"
paint:
line-color: "#00ff00"
line-width: 2
parkLayer:
id: parks
type: fill
source:
type: geojson
url: "https://example.com/parks.geojson"
paint:
fill-color: "#228B22"
fill-opacity: 0.5
pages:
- path: "/"
title: "Home"
blocks:
- type: map
id: main-map
config:
center: [-74.006, 40.7128]
zoom: 12
layers:
- $ref: "#/layers/bikeLayer"
- $ref: "#/layers/parkLayer"

With Global Sources

sources:
earthquakeSource:
type: geojson
url: "https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_day.geojson"
refreshInterval: 60000
layers:
earthquakes:
id: earthquakes
type: circle
source: earthquakeSource
paint:
circle-radius: 8
circle-color: "#ff0000"
pages:
- path: "/"
title: "Earthquakes"
blocks:
- type: map
id: quake-map
config:
center: [0, 0]
zoom: 2
mapStyle: "..."
layers:
- $ref: "#/layers/earthquakes"

Multi-Page Application

config:
title: "Multi-Page Map App"
defaultMapStyle: "https://demotiles.maplibre.org/style.json"
pages:
- path: "/"
title: "Home"
blocks:
- type: content
content:
- h1: [{ str: "Welcome" }]
- path: "/map"
title: "Interactive Map"
blocks:
- type: map
id: main-map
config:
center: [0, 0]
zoom: 2
- path: "/story"
title: "Our Story"
blocks:
- type: scrollytelling
id: story
config:
center: [0, 0]
zoom: 2
chapters:
- id: intro
title: "Introduction"
center: [0, 0]
zoom: 3