feat: support SVG symbols (DHIS2-14440) #517
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR adds support for SVG images as map symbols.
Fixes:
https://dhis2.atlassian.net/browse/DHIS2-14440
Partly fixes:
https://dhis2.atlassian.net/browse/DHIS2-14438
MapLibre GL JS don't support SVG images: mapbox/mapbox-gl-js#5529
We translate the SVG image to a HTML Image element before it's added to the map.
We need to know the size when the SVG is translated. Currently we only support the size used for symbols in DHIS2 (16x16). This could be expanded later (by passing in with and height together with the SVG URL).
The PR also includes a fix so the addImages Promise.all will resolve if one image could not be loaded. If there is an issue with one image, we will write it to the console, but still show the others.
After this PR (the triangle symbol is originally SVG):