Currently it is difficult to generate a custom implementation of a legend for a map layer without relying directly on the Legend map component/widget. To build a bespoke legend UI, an application developer typically has to:
- Add significant custom logic to process a renderer into HTML for display, or
- For OGC services, make additional calls to external services to obtain legend information.
At the same time, there is clearly existing logic in the Legend view model for producing HTML (or DOM structure) for different layer types, but this logic is not programmatically exposed for reuse.
Proposed solution
Introduce a set of reusable utilities (similar in spirit to existing symbolUtils) to generate legend content for a given layer. For example a function that, given a Layer (or renderer), returns a structured or HTML representation of its legend items.
The utility would be similar to the renderPreviewHTML function.
