Dear all,
as dash-leaflet still has no dl.Legend (or at least I am not aware of it, one way to add legend it is with predefined image), but is it possible to add callbacks to the dl.Overlays which contains the data shown on the dl.Map and show legend only on these Overlays which are checked.
I made an dl.Overlay(dl.GeoJSON(url=geojson, id=‘links-ch2th02-1’, checked=True) and later added the callback to it:
@app.callback(Output(‘ch2-th2-legend1’, “children”),
Input(‘links-ch2th02-1’, “checked”))
def add_legend_ch2th2(leg1):
msg = [html.H3(‘Legend’)]
if leg1:
msg+=[dbc.Row(‘My detailed legend’)]
return msg
but when uncheck the Overlay in the map, ‘My detailed legend’ still exist as a text.