Manual sprite protocol
  1. Render SVGs into sprite assets (JSON + PNG bytes).
  2. Register sprite://demo with SpriteBuilder.registerMapLibreProtocol.
  3. Point the style at sprite://demo.

Tip: The helper registerSpriteFromIcons (alias of registerProtocolFromIcons) wraps these steps for you. For example:


import maplibregl from 'maplibre-gl';
import { registerSpriteFromIcons } from 'maplibre-gl-svg-sprite';

const icons = { marker: '<svg width="24" height="24" ...>...</svg>' };
await registerSpriteFromIcons(maplibregl, 'sprite', 'demo', icons, [1, 2]);
// style.sprite = 'sprite://demo'