Class: Toggle

ol.control. Toggle


new Toggle( [options])

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

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

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)


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.


toggle()

Toggle control state active/deactive