-
Notifications
You must be signed in to change notification settings - Fork 55
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
Legend for print map #1408
Legend for print map #1408
Conversation
I have tested against WMS and WFS using Geoserver and it works like a charm. But I have some observations:
I noticed that onRender is now async. Nothing wrong with that, I'm a huge fan of async myself and something has to be a promise when calling the server. But as there is no await, all errors except those swallowed when the remote call is performed, will end up as uncaught (in promise). Maybe that is not a problem as previously I assume all errors would have ended up as uncaught anyway as the way I understand it, the code that calls onRender did not catch anything. But it could be worth contemplating if it affects anything else. |
Works well for me |
It doesn't crash if a feature layer lacks a style property in index.json, instead a wfs layer will be present and without an icon, an AGS_FEATURE layer will not be present (in the legend). It does seem to crash if a WMS layer does not have a style when Save image is employed. |
Correction: it does seem to crash if a WMS layer does not have a style property in index json and its source is local but defined in absolute terms, was getting 'tainted canvas' on toBlob() https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image . I tried a WMS service from another place (from a source defined in absolute terms) and it worked without a style (no legend icon but present in the legend). The local source expressed as a relative path also worked. The legend icons do seem to match the rest of the print, resolutionwise (and less console.log after the last commit) so I think it works well enough. We may choose to merge the other print PR before this one. |
@Grammostola Is this good to merge before 2.5? If so please resolve the conflicts. |
From what I've seen yes, it's mergable. The legend is optional in the printing pane and onRender being async hasn't produced anything unforseen while testing. |
Proposes to fix #1382
Adds a legend to the print maps top left corner that displays legends for all selected layers. Styles from index.json will be considered first. If a style is not found in index.json and layer is not of an AGS type then a call to getLegendGraphic will be made to the layer's source.
The legend can be hidden with the control menu.
Tested using:
WMS
,WFS
,GeoServer
,ArcGIS