geostyler / geostyler-legend

Small library to render map legends with OpenLayers and d3
BSD 2-Clause "Simplified" License
12 stars 9 forks source link

PNG output / Make sure rule icons are correctly drawn #422

Closed jahow closed 1 year ago

jahow commented 1 year ago

This fixes an issue where, under certain conditions, some rule icons were not correctly rendered in the legend.

This is because the png output does not wait for the load event of the rule icon images. This would sometimes give empty rule icons like so:

image

This PR makes sure that the images are always loaded before being drawn in the legend, by making the addImage method asynchronous. This does not impact the API of the library, nor the SVG output which did not face this issue in the first place.

Found as part of https://github.com/camptocamp/inkmap/pull/61