Skip to content

PopupContentItemSchema

const PopupContentItemSchema: z.ZodType<{[key: string]: unknown; alt?: string; else?: string; format?: string | PopupNumberFormat; href?: string; property?: string; src?: string; str?: string | { $html: string; }; target?: string; text?: string; }>

Defined in: packages/core/src/schemas/layer.schema.ts:230

Content item for popup or dynamic text rendering.

Supports static strings, dynamic property interpolation, and fallback values.

Properties:

  • str - Static text string
  • property - Feature property name to interpolate
  • else - Fallback value if property is missing
  • format - How a numeric property is written, with MapLibre’s number-format options: locale, currency, unit, min-fraction-digits, max-fraction-digits (formatted with Intl.NumberFormat, in the page’s language unless locale is given). The older d3-style string (",.0f") still works.
  • href - Link URL: absolute (https:, http:, mailto:, tel:) or a relative path (/about, ./notes.html, #top). Other schemes, such as javascript:, render as plain text.
  • text - Link text (falls back to str, then to the URL itself)
  • target - Where the link opens: _blank (default, with rel="noopener noreferrer"), _self, _parent or _top
  • src - Image source URL
  • alt - Image alt text

Static Text

- str: "Population: "

Dynamic Property

- property: name
else: "Unknown"

Formatted Number

- property: population
format: { max-fraction-digits: 0 }
- property: price
format: { currency: EUR, locale: de-DE }

Link (`str` or `text` is the link text)

- str: "Wikipedia"
href: "https://en.wikipedia.org/wiki/Chicago"
target: _self