from ipyleaflet import Map, LegendControl
mymap = Map(center=(-10,-45), zoom=4)
mymap
Map(center=[-10, -45], controls=(ZoomControl(options=['position', 'zoom_in_text', 'zoom_in_title', 'zoom_out_t…
By default, you need to provide at least a dictionnary with pair key=> the label to display and value=> the desired color. By default, it is named 'Legend', but you can pass a name as argument as well.
a_legend = LegendControl({"low":"#FAA", "medium":"#A55", "High":"#500"}, name="Legend", position="bottomright")
mymap.add_control(a_legend)
a_legend.name = "Risk" ## set name
a_legend.name # get name
'Risk'
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.positionning ="topright" # set positionning : possible values are topleft, topright, bottomleft, bottomright
a_legend.positionning # get current positionning
'topright'