Attach a popup to a marker instance
Replicates the MapLibre example Attach a popup to a marker instance. The upstream marker.setPopup(new Popup().setHTML(...)) becomes a popup: block on the marker — the same trust-gated structured content as layer popups, so untrusted documents can’t inject markup.
The complete document
Section titled “The complete document”# yaml-language-server: $schema=https://docs.maplibre-yaml.org/schema/latest/map.schema.json# Gallery twin of https://maplibre.org/maplibre-gl-js/docs/examples/attach-a-popup-to-a-marker-instance/# A marker with structured popup content — same trust-gated vocabulary# as layer popups.type: mapid: attach-a-popup-to-a-marker-instanceconfig: center: [12.55, 55.665] zoom: 8 mapStyle: "https://demotiles.maplibre.org/style.json"markers: - at: [12.55, 55.665] color: "#e63946" popup: - h3: - str: "Hello Copenhagen!" - p: - str: "Click the pin to toggle me."What to notice
Section titled “What to notice”- Marker popups use the identical content vocabulary as
click.popupon layers — tags are allowlisted, values escaped. - Clicking the marker toggles the popup, MapLibre’s built-in behavior.