Search code examples
javascriptautodesk-forgemarkupautodesk-viewer

Save and Load Pushpin Markup by SVG


I following this tutorial https://forge.autodesk.com/blog/create-pushpin-markup-svg for create SVG markup on 3D view. Everything are fine when i put the markup in my 3D viewer. But, do you know how to save these markups on my database and load it again into viewer ? Thank you.


Solution

  • The first idea is similar to what I did in the blog, store the pushpin geometry data (type, position, radius etc), and render the pushpin again with the same logic like the blog codes does.

    While, the other general way is to serialize the svg to base64 string. Convert inline SVG to Base64 string and set src of the svg with the base64 when loading the pushpin next time: How to set base64 svg string to image tag src?

    Actually, Markup of Forge Viewer is also SVG. It provides the method markupsExtension.generateData() which also turns to call xmlSerializer.serializeToString to generate the base64 string.

    Hope this helps.