Add an icon to the map
Replicates the MapLibre example Add an icon to the map. The upstream map.loadImage(...) + map.addImage(...) pair becomes a declarative images: entry.
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/add-an-icon-to-the-map/# images: declares named images the document's layers reference; they load# before layers live, and merge into the emitted sprite on export.type: mapid: add-an-icon-to-the-mapconfig: center: [0, 0] zoom: 1 mapStyle: "https://demotiles.maplibre.org/style.json"images: osgeo-logo: "https://maplibre.org/maplibre-gl-js/docs/assets/osgeo-logo.png"sources: point: type: geojson data: type: FeatureCollection features: - type: Feature geometry: { type: Point, coordinates: [0, 0] } properties: {}layers: - id: logo type: symbol source: point layout: icon-image: osgeo-logoWhat to notice
Section titled “What to notice”images:names load before layers, soicon-image: osgeo-logoresolves on first render — nostyleimagemissingrace.- On export (
mlym emit), the image is fetched at compile time and merged into the document sprite; the layer’s reference is rewritten tomlym:osgeo-logo. Theimages:construct fully compiles — classexports, so--strictaccepts it. - Options ride along per entry:
{ url, sdf, pixelRatio }instead of the bare URL string.