Optionaloptions: SVGExportControlOptions
The panel's initial image size. Both default to the map's size.
Called by MapLibre when the control is added with map.addControl(); not meant to be
called directly. Returns the button to place on the map.
Called by MapLibre when the control is removed with map.removeControl(); not meant
to be called directly. Closes the panel and cleans up.
A MapLibre GL JS control that exports the current map view as an SVG image.
Adds a button to the map. Clicking it opens a panel with a live preview of the view as SVG, where the user can set the image size, choose whether to include labels and icons, and then download the file or open it in a new tab. The map stops responding to panning and zooming while the panel is open, so the preview matches what is exported.
The preview is rendered with renderToSVG from the map's current style, centre and zoom, and the panel shows the attribution of the style's sources.
Example: With a bundler
Example: With a script tag
The UMD bundle, served by jsDelivr, exposes everything on a global
VersaTilesSVG:Example: Start the panel at a fixed size