sepal_ui.mapping.legend_control.LegendControl#

class sepal_ui.mapping.legend_control.LegendControl(**kwargs)[source]#

A custom Legend widget ready to be embed in a map.

This Legend can be control though it’s different attributes, changing it’s position of course but also the orientation ,the keys and their colors.

New in version 2.10.4.

Parameters:
  • legend_dict (Dict) – the dictionary to fill the legend values. cannot be empty.

  • title (Unicode) – title of the legend, if not set a default value in the current language will be used

  • vertical (Bool) – the orientation of the legend. default to True

Attributes

legend_dict

Dictionary with key as label name and value as color

title

Title of the legend.

vertical

Whether to display the legend in a vertical or horizontal way

Methods

__init__

A custom Legend widget ready to be embed in a map.

color_box

Returns an rectangular SVG html element with the provided color.

hide

Hide control by hiding its content.

show

Show control by displaying its content.

LegendControl.__init__(legend_dict={}, title='Legend', vertical=True, **kwargs)[source]#

A custom Legend widget ready to be embed in a map.

This Legend can be control though it’s different attributes, changing it’s position of course but also the orientation ,the keys and their colors.

New in version 2.10.4.

Parameters:
  • legend_dict (dict) – the dictionary to fill the legend values. cannot be empty.

  • title (str) – title of the legend, if not set a default value in the current language will be used

  • vertical (bool) – the orientation of the legend. default to True

Return type:

None

static LegendControl.color_box(color, size=35)[source]#

Returns an rectangular SVG html element with the provided color.

Parameters:
  • color (str | tuple) – It can be a string (e.g., ‘red’, ‘#ffff00’, ‘ffff00’) or RGB tuple (e.g., (255, 127, 0))

  • size (int) – the size of the legend square

Returns:

The HTML rendered color box

Return type:

HTML

LegendControl.hide()[source]#

Hide control by hiding its content.

Return type:

None

LegendControl.show()[source]#

Show control by displaying its content.

Return type:

None