Load SVG icons dynamically into MapLibre. No build step. No PNG files. Just pure SVG → sprite magic.
// 1. Load your SVGs
const icons = [
{ id: 'marker', svg: markerSvg },
{ id: 'star', svg: starSvg }
];
// 2. Register sprite protocol
await registerSpriteFromIcons(
maplibregl,
'sprite',
'my-icons',
icons
);
// 3. Use in your style
style: {
sprite: 'sprite://my-icons',
// ...
}