Class: Toggle

ol.control. Toggle

A simple toggle control The control can be created with an interaction to control its activation.


new Toggle( [options])

Parameters:
Name Type Argument Description
options Object <optional>

Control options.

Properties
Name Type Description
className String

class of the control

title String

title of the control

html String

html to insert in the control

interaction ol.interaction

interaction associated with the control

active bool

the control is created active, default false

disable bool

the control is created disabled, default false

bar ol.control.Bar

a subbar associated with the control (drawn when active if control is nested in a ol.control.Bar)

autoActive bool

the control will activate when shown in an ol.control.Bar, default false

onToggle function

callback when control is clicked (or use change:active event)

Fires:
  • change:active,event: change:disable

Extends

Methods


getActive()

Test if the control is active.

Returns:

.

Type
bool

getButtonElement()

Get the button element

Inherited From:
Overrides:
Returns:
Type
Element

getDisable()

Test if the control is disabled.

Returns:

.

Type
bool

getInteraction()

Get the control interaction

Returns:

interaction associated with the control

Type
_ol_interaction_

getSubBar()

Get the subbar associated with a control

Returns:
Type
ol.control.Bar

setActive(b)

Change control state

Parameters:
Name Type Description
b bool

activate or deactivate the control, default false


setDisable(b)

Disable the control. If disable, the control will be deactivated too.

Parameters:
Name Type Description
b bool

disable (or enable) the control, default false (enable)


setHtml(html)

Set the button html

Parameters:
Name Type Description
html string
Inherited From:
Overrides:

setInteraction(i)

Set the control interaction

Parameters:
Name Type Description
i _ol_interaction_

interaction to associate with the control


setMap(map)

Set the map instance the control is associated with and add interaction attached to it to this map.

Parameters:
Name Type Description
map _ol_Map_

The map instance.


setSubBar( [bar])

Set the subbar associated with a control

Parameters:
Name Type Argument Description
bar ol.control.Bar <optional>

a subbar if none remove the current subbar


setTitle(title)

Set the button title

Parameters:
Name Type Description
title string
Inherited From:
Overrides:

setVisible(b)

Set the control visibility

Parameters:
Name Type Description
b boolean
Inherited From:
Overrides:

toggle()

Toggle control state active/deactive