Skip to content

Commit

Permalink
Legend icon - now datauri set as image element;
Browse files Browse the repository at this point in the history
Chrome would invalidate datauri set as background-image on a div;
  • Loading branch information
cityremade committed Apr 12, 2024
1 parent c33d1e6 commit c913a1e
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions lib/ui/elements/legendIcon.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,20 @@ function createIconFromArray(style) {
}

function createIconFromInlineStyle(style) {

const inlineStyle = `
background-position: center;
background-repeat: no-repeat;
background-size: contain;
width: ${style.width + 'px' || '100%'};
height: ${style.height + 'px' || '100%'};
background-image: url(${style.icon?.svg || style.svg || style.icon?.url || style.url || mapp.utils.svgSymbols[style.icon?.type || style.type](style.icon || style)})`;
background-position: center;
background-repeat: no-repeat;
background-size: contain;`

return mapp.utils.html`<div style=${inlineStyle}>`;
const imgInlineStyle = `
width: ${(style.width + 'px') || '100%'};
height: ${(style.height + 'px') || '100%'};
`;

const src = style.icon?.svg || style.svg || style.icon?.url || style.url || mapp.utils.svgSymbols[style.icon?.type || style.type](style.icon || style);

return mapp.utils.html`<div style=${inlineStyle}><img style=${imgInlineStyle} src=${src}>`
}

function createLineSymbol(style) {
Expand Down

0 comments on commit c913a1e

Please sign in to comment.