From 625c5e0e09c6ee9c2ab3d5afb56af89cd148c970 Mon Sep 17 00:00:00 2001 From: nikki-kiga <42276368+nikki-kiga@users.noreply.github.com> Date: Thu, 16 Dec 2021 16:10:52 -0800 Subject: [PATCH] Geomap: Add default svg size (#43246) * add default svg size --- public/app/plugins/panel/geomap/style/markers.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/panel/geomap/style/markers.ts b/public/app/plugins/panel/geomap/style/markers.ts index a643ab97bc8..3accfd7f82d 100644 --- a/public/app/plugins/panel/geomap/style/markers.ts +++ b/public/app/plugins/panel/geomap/style/markers.ts @@ -216,7 +216,7 @@ const makers: SymbolMaker[] = [ }, ]; -async function prepareSVG(url: string): Promise { +async function prepareSVG(url: string, size?: number): Promise { return fetch(url, { method: 'GET' }) .then((res) => { return res.text(); @@ -228,8 +228,15 @@ async function prepareSVG(url: string): Promise { 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}`;