map0

Configuration

Validate a config

Check a config before loading the map. Validation errors identify the affected setting by its JSON path. This page uses the viewer’s validator and explains where else validation can run.

Paste a config

This page runs map0’s validateConfig. Errors prevent the map from loading. Warnings, such as unknown keys, allow it to load while drawing attention to settings that may need checking.

Inheritance: the viewer resolves extends before validation, so a child config may inherit its basemaps. This page validates the pasted document as it is.

Every place a config is checked

In your editor, as you type

Add a $schema entry to associate the config with its JSON Schema. Editors such as VS Code and JetBrains can use it for completion, hover documentation and validation:

my-map.map0.json
{
  "$schema": "https://map0.net/schema/v1.json",
  "version": 1,
  "basemaps": [{ "type": "style", "url": "…" }]
}

In CI, before it ships

Use a JSON Schema validator in your build pipeline or when saving a config in the CMS:

shell
npx ajv-cli validate -s node_modules/map0-viewer/schema/v1.json -d my-map.map0.json

check-jsonschema provides a Python option. The schema checks keys, types, value ranges and required fields.

Before the config: the service itself

A valid config can still show an empty map when the service behind it blocks cross-origin requests, has no Web Mercator tiles or serves no real GeoJSON. map0-check probes a WMS, WMTS, WFS or OGC API Features URL with the requests map0 sends and prints the verdict, the reasons and the layer definition to paste:

shell
npx map0-check "https://data.wien.gv.at/daten/geo?service=WMS&request=GetCapabilities" --layer TRINKBRUNNENOGD

--config wraps the result into a complete config, --json gives a machine-readable report with an exit code for CI. Details on the map0-check package page.

In your own code

The npm package exports the validator through its SSR entry. It can run in Node without a DOM, for example to check a config before saving it:

save-hook.js
import { validateConfig } from "map0-viewer/ssr";

const { valid, errors, warnings } = validateConfig(config);
// errors: [{ path: "$.layers[0].url", message: 'a "wms" layer needs a "url"' }]

In the viewer, always

The viewer validates again before rendering and displays errors in place. Its checks include URL rules, unique IDs across basemaps and layers, and relationships between fields, such as a colour ramp’s min being less than its max.

error panel
$.basemaps          at least one basemap is required, e.g. { "type": "style", "url": "…" }
$.layers[2].url     a "wms" layer needs a "url"
$.layers[2].layers  a "wms" layer needs "layers" (WMS LAYERS parameter)

The schema, published

The same schema is available at three locations:

The filename refers to the config format version ("version": 1). Descriptions in the schema provide editor documentation. Tests compare its keys and enums with the runtime validator.