Legend

Constructor

new Legend()

Custom Leaflet control which will display a legend for colour-coded values.

Options:

  • id Unique id for the control
  • position The location on the map (using leaflet's standard control positions). Default: bottomright
  • collapse True to show a button until clicked, then show the legendbox; false to just show the expanded legend box. Default: false
  • label The label to give to the list of legend colours, set to null for no label. Default: null
  • title The title the button when collapse=true. Default: 'Show legend'
  • items array of items to be displayed in the legend. Each item is an object with the following properties:
    • redRed value for the RGB colour indicator
    • greenGreen value for the RGB colour indicator
    • blueBlue value for the RGB colour indicator
    • nameThe text to be displayed
    • iconClass The CSS class(es) for the button icon (if collapse=true). Default: 'fa fa-list'
    • legendListClass The CSS class(es) legend list container. Default: none