from ipyleaflet import Map, LegendControl
mymap = Map(center=(-10, -45), zoom=4)
mymap
By default, you need to provide at least a dictionary with pair key=> the label to display and value=> the desired color. By default, it is titled 'Legend', but you can pass a title as argument as well.
a_legend = LegendControl(
{"low": "#FAA", "medium": "#A55", "High": "#500"},
title="Legend",
position="bottomright",
)
mymap.add(a_legend)
a_legend.title = "Risk" ## set title
a_legend.title # get title
a_legend.legends = {"el1": "#FAA", "el2": "#A55", "el3": "#500"} # set content
a_legend.legends # get content
a_legend.add_legend_element("el5", "#000") # add a legend element
a_legend.remove_legend_element("el5") # remove a legend element
a_legend.positioning = "topright" # set positioning : possible values are topleft, topright, bottomleft, bottomright
a_legend.positioning # get current positioning