Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Jan 2, 2023

Conversation

jahow
Copy link
Contributor

@jahow jahow commented Dec 28, 2022

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 camptocamp/inkmap#61

This will be used to wait for the image to properly load the data encoded
as base64

Also adjusted the jest config to let JSDOM know that it should actually
load image resourcs, see:
https://github.com/jsdom/jsdom#loading-subresources

This is required for the 'load' event of the image to trigger in the tests.
Copy link
Contributor

@jansule jansule left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice! Thanks @jahow

@jansule jansule merged commit bd47184 into geostyler:master Jan 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants