Get SVG content receives from API and add as ImageOverlay in Leaflet

94 Views Asked by At

1. I manually copied the svg content to a svgMap.svg and accessed as follow

var imageUrl = 'assets/img/svgMap.svg';
L.imageOverlay(imageUrl, imageBounds, {opacity: 0.7}).addTo(map);

and this its working as expected.

Since there I coudnt find a way to save those svg content in the server side. I used jaggery.js, so that I could access the svg image in the same way I accessed it before.

2. jaggery.js File.write() encodes special characters ( eg: apostrophe )

This didn't work, though, because jaggery.js encodes special characters. I wanted to write a svg content on a file (svgContent.svg) when using the following

var file = new File("../filePath" + "fileName.svg");
file.open("w");
file.write(svgMap);
file.close();

This is because jjaggery.js encodes with latin1 and svg content is in UTF-8.

Are there any alternative way to get this SVG content to the image overlay?

0

There are 0 best solutions below