Skip to content
Last updated

API / geotoolkit / controls / toolbar / Toolbar / Toolbar

Class: Toolbar

toolbar.Toolbar.Toolbar

Toolbar with the provided styles and buttons. Style can be completely changed via css. Creates css structure as follows: Toolbar Container (.cg-toolbar-container class) <ul> <li> Canvas </li> <li> Toolbar #1 </li> <li> Toolbar #2 </li> <li> ... </li> </ul>

Each toolbar has one of the following css class: .cg-toolbar-left,.cg-toolbar-top,.cg-toolbar-right,.cg-toolbar-bottom depending on its orientation and alignment. The toolbar content consists of button group(s) with .cg-toolbar-group style. Groups, in turn, contain buttons (.cg-toolbar-button). To separate the buttons into groups, use special symbol '-' (see examples).

Example

import {Toolbar} from '@int/geotoolkit/controls/toolbar/Toolbar';
import {AnchorType} from '@int/geotoolkit/util/AnchorType';
import {Orientation} from '@int/geotoolkit/util/Orientation';
new Toolbar({
// vertical toolbar in the upper right canvas corner:
'alignment': AnchorType.RightTop,
'orientation': Orientation.Vertical,
// some styles can be set in the constructor, e.g. the buttons size (in px):
'size': 40,
// set the list of buttons, see @int/geotoolkit/controls/toolbar/ButtonRegistry for a complete list:
'buttons': &#91;
'zoom-in',
'zoom-out',
'-', // special symbol to separate buttons group for a gap
['point-selection', 'polygon-selection'&#93; // use an array to create automatic dropdown
],
'tools': plot.getTool() // link to plot
});

Example

// custom buttons can be created and used in the toolbar directly:
import {Button} from '@int/geotoolkit/controls/toolbar/Button';
new Toolbar({
...,
'buttons': &#91;
'zoom-in',
'zoom-out',
new Button({
'icon': 'fas fa-cat', // set icon for a button
'title': 'Hello World', // title (hover text) info
'action': (tools, enabled) =&gt; { // button pressing callback
alert('Hello, World!');
}
})
&#93;,
'tools': plot.getTool()
});

Implements

Table of contents

Constructors
  • [new Toolbar(options)](/solutions/geotoolkit/GeoToolkit_JS/apis/classes/geotoolkit.controls.toolbar.toolbar.toolbar.md#new toolbar(options))
Methods

Contents

Constructors

new Toolbar(options)

• new Toolbar(options)

Parameters

Name Type
optionsOptions
Methods

dispose

▸ dispose(): void

Disposes this toolbar, once disposed it should not be used anymore. Clear all listeners, and removes buttons from the document.

Returns

void

Implementation of

IDisposable.dispose


getButtonList

▸ getButtonList(): Button[][]

Returns button two-dimensional array of grouped toolbar button

Returns

Button[][]


getClassName

▸ getClassName(): string

Returns

string


getElement

▸ getElement(): HTMLElement

Return tool bar element

Returns

HTMLElement

element


getOffset

▸ getOffset(): Point

Return toolbar offset

Returns

Point

offset


getSize

▸ getSize(): number

Return toolbar button size

Returns

number


getVisible

▸ getVisible(): boolean

Get toolbar visibility

Returns

boolean


insertButton

▸ insertButton(groupId, buttonId, button): Toolbar

Insert button at a specific position

Parameters

Name Type Description
groupIdnumberbutton group id (groups were separated with '-' symbol)
buttonIdnumberbutton index position inside the group
buttonstring | Buttontoolbar button to insert or its string identifier (see geotoolkit.controls.toolbar.ButtonRegistry.getInstance().getIds() for all the buttons available)

Returns

Toolbar

this


removeButton

▸ removeButton(button): Toolbar

Removes button from toolbar

Parameters

Name Type Description
buttonButtontoolbar button to remove

Returns

Toolbar

this


setOffset

▸ setOffset(offset): Toolbar

Set toolbar offset

Parameters

Name Type Description
offsetnumber | Point | Options | Dimensiontoolbar offset (in pixel)

Returns

Toolbar


setVisible

▸ setVisible(visible): Toolbar

Set toolbar visibility

Parameters

Name Type Description
visiblebooleanvisibility flag

Returns

Toolbar


getClassName

▸ Static getClassName(): string

Returns

string