Skip to content
Last updated

API / geotoolkit / map / toolbar / ZoomLevel / ZoomLevel

Class: ZoomLevel

toolbar.ZoomLevel.ZoomLevel

This class provides a way to show the map’s current zoom level on a canvas element at a chosen location. It helps identify the updated zoom level after the user performs zoom‑in or zoom‑out actions.

Example

const plot = new Plot({
'canvaselement': canvas,
'root': map
});
// create new toolbar:
new Toolbar({
'color': '#adb6c2',
'offset': {
x: 4,
y: 4
},
'buttons': [
new ZoomLevel(), // By default, it shows only the current zoom level without decimals
'-',
// to display custom text along with the current zoom level, formatted to four decimal places.
new ZoomLevel({
'formatter': (value: number) => 'Zoom level: ' + value.toFixed(4),
'map: map
}),
],
'orientation': Orientation.Horizontal,
'alignment': AnchorType.RightBottom,
'tools': plot.getTool()
});

Hierarchy

Table of contents

Constructors
  • [new ZoomLevel(options)](/solutions/geotoolkit/GeoToolkit_JS/apis/classes/geotoolkit.map.toolbar.zoomlevel.zoomlevel.md#new zoomlevel(options))
Methods

Contents

Constructors

new ZoomLevel(options)

• new ZoomLevel(options?)

Parameters

Name Type Description
Optional optionsOptionsZoomLevel options

Overrides

Label.constructor

Methods

clear

▸ clear(tools, registry): void

Clears this button, removes all listeners and button DOM element from the document.<br> Calls user callback with the ToolsContainer provided and 'false' flag to clear the data. Removes itself from the registry list.

Parameters

Name Type Description
toolsToolsContainertools container for the user callback
registryButton[]button registry to remove itself from

Returns

void

Inherited from

Label.clear


clone

▸ clone(): Button

All subclasses should override copyConstructor or provide custom implementation for this method

Returns

Button

clone

Inherited from

Label.clone


copyConstructor

▸ Protected copyConstructor(src): ZoomLevel

Copy constructor function.<br> Function used as part of the cloning mechanism.<br> Implementations should copy the given instance state to this instance.<br>

Parameters

Name Type Description
srcZoomLevelSource to copy from

Returns

ZoomLevel

this

Overrides

Label.copyConstructor


getAction

▸ getAction(): ActionCallback

Returns current action callback (if exists)

Returns

ActionCallback

Inherited from

Label.getAction


getBorder

▸ getBorder(): string

Returns button element border

Returns

string

Inherited from

Label.getBorder


getChecked

▸ getChecked(): boolean

Returns true if button is checked (for checkbox case), false otherwise

Returns

boolean

Inherited from

Label.getChecked


getClassName

▸ getClassName(): string

Returns

string

Inherited from

Label.getClassName


getColor

▸ getColor(): string

Returns button element background color

Returns

string

Inherited from

Label.getColor


getElement

▸ getElement(): HTMLElement

Returns current html DOM element used for the button

Returns

HTMLElement

Inherited from

Label.getElement


getFormatter

▸ getFormatter(): (zoomLevel: number) => string

return formatter function.

Returns

fn

function

▸ (zoomLevel): string

return formatter function.

Parameters
Name Type
zoomLevelnumber
Returns

string

function


getHeight

▸ getHeight(): number

Returns fixed button height in px (if was set), null otherwise

Returns

number

Inherited from

Label.getHeight


getIcon

▸ getIcon(): string

Returns button icon

Returns

string

Inherited from

Label.getIcon


getInit

▸ getInit(): InitCallback

Returns current initialization callback to be called on toolbar init/dispose

Returns

InitCallback

initialization callback

Inherited from

Label.getInit


getName

▸ getName(): string[]

Returns current name(s) that describe group(s) that the radio button belongs to (checkbox case only). If the button should not switch automatically or is not checkbox, returns empty array

Returns

string[]

Inherited from

Label.getName


getPaddingStyle

▸ getPaddingStyle(): string

Returns button element padding style

Returns

string

Inherited from

Label.getPaddingStyle


getTextColor

▸ getTextColor(): string

Returns button element text color

Returns

string

Inherited from

Label.getTextColor


getTitle

▸ getTitle(): string

Returns button DOM element title text

Returns

string

Inherited from

Label.getTitle


getWidth

▸ getWidth(): number

Returns fixed button width in px (if was set), null otherwise

Returns

number

Inherited from

Label.getWidth


init

▸ init(tools, registry, parent, gap, insertId, listener): ZoomLevel

Initializes button, creates event listeners and adds button element to the document

Parameters

Name Type Description
toolsToolsContainertools container for the user callback
registryButton[]list of buttons on the Plot, is needed for correct on/off radio buttons
parentHTMLElementparent element to add button to
gapHTMLElementgap element or null if no gap is needed
insertIdnumberinsert position index
listener(b: Button) => voidlistener callback

Returns

ZoomLevel

this

Inherited from

Label.init


setAction

▸ setAction(action): ZoomLevel

Sets current action callback

Parameters

Name Type Description
actionActionCallbackaction callback to be called when pressing the button

Returns

ZoomLevel

this

Inherited from

Label.setAction


setBorder

▸ setBorder(border): ZoomLevel

Sets button element border

Parameters

Name Type Description
borderstringcss-styled border value

Returns

ZoomLevel

this

Inherited from

Label.setBorder


setChecked

▸ setChecked(checked): ZoomLevel

Adds or removes css checked class to the DOM element

Parameters

Name Type Description
checkedbooleantrue to add checked class, false otherwise

Returns

ZoomLevel

this

Inherited from

Label.setChecked


setColor

▸ setColor(color): ZoomLevel

Sets button element background color

Parameters

Name Type Description
colorstringbackground color

Returns

ZoomLevel

this

Inherited from

Label.setColor


setFormatter

▸ setFormatter(formatter): ZoomLevel

set formatter to get custom zoom level.

Parameters

Name Type
formatter(zoomLevel: number) => string

Returns

ZoomLevel

this


setIcon

▸ setIcon(icon): ZoomLevel

Set button icon

Parameters

Name Type
iconstring

Returns

ZoomLevel

Inherited from

Label.setIcon


setInit

▸ setInit(init): ZoomLevel

Sets initialization callback that is called on toolbar init/dispose

Parameters

Name Type Description
initInitCallbackinitialization callback

Returns

ZoomLevel

this

Inherited from

Label.setInit


setPaddingStyle

▸ setPaddingStyle(padding): ZoomLevel

Sets button element padding style

Parameters

Name Type Description
paddingstring | numberpadding (in px) or style string

Returns

ZoomLevel

Inherited from

Label.setPaddingStyle


setSize

▸ setSize(width, height?): ZoomLevel

Sets button DOM element fixed size (in px)

Parameters

Name Type Description
widthnumberbutton element size or width
Optional heightnumberbutton element height. Equals to width, if nothing is provided.

Returns

ZoomLevel

this

Inherited from

Label.setSize


setText

▸ setText(text): ZoomLevel

Set label text

Parameters

Name Type Description
textstringlabel text

Returns

ZoomLevel

Inherited from

Label.setText


setTextColor

▸ setTextColor(color): ZoomLevel

Sets button element text color

Parameters

Name Type Description
colorstringtext color

Returns

ZoomLevel

this

Inherited from

Label.setTextColor


setTitle

▸ setTitle(title): ZoomLevel

Sets button DOM element title

Parameters

Name Type Description
titlestringtitle text

Returns

ZoomLevel

Inherited from

Label.setTitle


getClassName

▸ Static getClassName(): string

Returns

string

Inherited from

Label.getClassName