You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
It is hard to distinguish symbol layers on the legend, since they have the same symbol. The more such layers you have, the harder it is . So I propose to read the symbol from the style specification and render it on the legend.
Describe the solution you'd like
The icon should be red from the style specification and rendered on the legend. The easiest way to do it is render it on a small canvas. Sample code to accomplish that for icon-images
functionget_legend_symbol(map,layer_id){/** * Returns an HTML element (canvas) with the symbol taken from the layer style * @param {Object} map - The map object * @param {String} layer_id: Id of the layer */conststyle=map.getStyle().layers.find(l=>l.id==layer_id)constcanvas=document.createElement('canvas')const[width,height]=[64,64]canvas.id=`${layer_id}_canvas`canvas.height=widthcanvas.width=heightcanvas.classList.add('legend-item')constimg=map.getImage(style.layout["icon-image"])constUAC=newUint8ClampedArray(img.data.data,width,height)constDAT=newImageData(UAC,width,height);constctx=canvas.getContext("2d")ctx.putImageData(DAT,0,0)returncanvas}
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered:
You can just write the icon name at icon-image if you use sprite and every layer has only one certain icon. In this way ,the legend will show the real icon. If one layer has more than one icon, which icon should the legend show ?
Is your feature request related to a problem? Please describe.
It is hard to distinguish symbol layers on the legend, since they have the same symbol. The more such layers you have, the harder it is . So I propose to read the symbol from the style specification and render it on the legend.
Describe the solution you'd like
The icon should be red from the style specification and rendered on the legend. The easiest way to do it is render it on a small canvas. Sample code to accomplish that for icon-images
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: