Display a remote SVG symbol
Replicates the MapLibre example Display a remote SVG symbol. Upstream fetches the SVG inside a missing-image resolver and adds it by hand. An images: entry does the same declaratively: the URL loads through an <img>, which rasterizes SVG at its intrinsic size, and the image is registered before any layer asks for it.
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/display-a-remote-svg-symbol/# Upstream fetches the SVG in a missing-image resolver and adds it by hand.# An `images:` entry does the same declaratively: the URL loads through an# <img>, which rasterizes SVG at its intrinsic size, before layers are added.type: mapid: display-a-remote-svg-symbolconfig: center: [0, 0] zoom: 1 maplibreLogo: true mapStyle: "https://demotiles.maplibre.org/style.json"images: maplibre-logo: "https://maplibre.org/maplibre-gl-js/docs/assets/logo.svg"layers: - id: svg-symbol type: symbol source: type: geojson location: coordinates: [0, 0] layout: icon-image: maplibre-logo icon-overlap: always text-overlap: alwaysWhat to notice
Section titled “What to notice”- The SVG needs an intrinsic size (
width/heighton the root element) and must be served with CORS headers. - On
mlym emitthe image is fetched at compile time and merged into the document’s sprite.