Skip to content

spatial-monorepo


spatial-monorepo / core/src / exportToSVG

Function: exportToSVG()

exportToSVG(map, opts?): Promise`<void>`

Defined in: packages/core/src/export/mapExport.ts:130

Export the current map view as an SVG file and trigger a browser download. Embeds the canvas raster as a base64 PNG inside an <image> element — this is a raster snapshot wrapped in an SVG container, not a true vector export. It does not scale losslessly and its contents are not editable as paths.

If you need actual vector output of IMDF floor-plan data (unit polygons and labels as real SVG paths/text), use exportFloorSVG instead.

Issue #429 — forces a fresh WebGL paint via map.triggerRepaint() and reads the canvas synchronously inside the next 'render' event so the export is never blank, regardless of the map's preserveDrawingBuffer setting (see getRenderedCanvas). This makes the function async; await it (or handle the returned Promise) before assuming the download has been triggered.

Parameters

map

Map$1

MapLibre GL map instance

opts?

ExportSVGOptions

Optional width, height (default: canvas dimensions) and filename

Returns

Promise`<void>`

Released under commercial licensing.