Class: Legend

ol.control. Legend

Create a legend for styles


new Legend(options)

Parameters:
Name Type Description
options *
Properties
Name Type Argument Default Description
className String

class of the control

title String <optional>
"legend"

control title

emptyTitle String <optional>
"no legend"

control title when legend is empty

legend ol.legend.Legend
collapsed boolean | undefined

Specify if legend should be collapsed at startup. Default is true.

collapsible boolean | undefined

Specify if legend can be collapsed, default true.

target Element | string | undefined

Specify a target if you want the control to be rendered outside of the map's viewport.

Fires:
  • event:select

Extends

Methods


collapse()

Show/hide control

Returns:
Type
boolean

getCanvas()

Get canvas overlay

Inherited From:
Overrides:

getFill()

Get fill

Inherited From:
Overrides:

getLegend()

Get the legend associated with the control

Returns:
Type
ol.legend.Legend

getStroke()

Get stroke

Inherited From:
Overrides:

getStyle()

Get style

Inherited From:
Overrides:

getTextFill()

Get text fill

Inherited From:
Overrides:

getTextFont()

Get text font

Inherited From:
Overrides:

getTextStroke()

Get stroke

Inherited From:
Overrides:

hide()

Hide control


isCollapsed()

Is control collapsed

Returns:
Type
boolean

onCanvas()

Is control on canvas

Returns:
Type
boolean

setCanvas(b)

Draw control on canvas

Parameters:
Name Type Description
b boolean

draw on canvas.


setMap(map)

Remove the control from its current map and attach it to the new map. Subclasses may set up event handlers to get notified about changes to the map here.

Parameters:
Name Type Description
map ol.Map

Map.

Inherited From:
Overrides:

setStyle()

Set Style

Inherited From:
Overrides:

show()

Show control


toggle()

Toggle control