@@ -216,7 +216,7 @@ const makers: SymbolMaker[] = [
|
||||
},
|
||||
];
|
||||
|
||||
async function prepareSVG(url: string): Promise<string> {
|
||||
async function prepareSVG(url: string, size?: number): Promise<string> {
|
||||
return fetch(url, { method: 'GET' })
|
||||
.then((res) => {
|
||||
return res.text();
|
||||
@@ -228,8 +228,15 @@ async function prepareSVG(url: string): Promise<string> {
|
||||
if (!svg) {
|
||||
return '';
|
||||
}
|
||||
|
||||
const svgSize = size ?? 100;
|
||||
const width = svg.getAttribute('width') ?? svgSize;
|
||||
const height = svg.getAttribute('height') ?? svgSize;
|
||||
|
||||
// open layers requires a white fill becaues it uses tint to set color
|
||||
svg.setAttribute('fill', '#fff');
|
||||
svg.setAttribute('width', `${width}px`);
|
||||
svg.setAttribute('height', `${height}px`);
|
||||
const svgString = new XMLSerializer().serializeToString(svg);
|
||||
const svgURI = encodeURIComponent(svgString);
|
||||
return `data:image/svg+xml,${svgURI}`;
|
||||
|
||||
Reference in New Issue
Block a user