Skip to content

StateSchema

const StateSchema: ZodRecord<ZodString, ZodObject<{ default: ZodAny; }, "passthrough", ZodTypeAny, objectOutputType<{ default: ZodAny; }, ZodTypeAny, "passthrough">, objectInputType<{ default: ZodAny; }, ZodTypeAny, "passthrough">>>

Defined in: packages/core/src/schemas/map.schema.ts:473

Runtime-tunable values carried at the document root.

state is a style-spec root property — MapLibre carries it natively and expressions read it via global-state — so it compiles through to the emitted style rather than degrading. It is accepted here ahead of the rest of format v2’s surface syntax, in the position v2 gives it, so an author who adopts it today has nothing to move later.

The authored shape is the spec’s own shape, { key: { default: value } }, not a flat { key: value }. This is the one place where “the erasable half is the spec” is literally true — state compiles through verbatim, with no transformation at all, unlike visible or before. Inventing a different spelling for the single key where that claim is exact would undercut it.

The sugar precedent set for GeoJSON does not transfer: location:/region: exist as sugar to protect content collections people already wrote, and no state: document exists yet. There is nothing to protect, so a second authored form would cost two-ways-to-author and buy nothing.

The {default: ...} wrapper is not gratuitous either — it is where the spec expects to add per-key fields, and a flattened form could not follow.

The spec’s state carries defaults only: no label, no type, no range. The metadata a control UI needs to render a picker lives in ParametersSchema instead, which does not compile through.