control.Manager

Manager for map controls.

Constructor | Fields | Methods

Constructor

control.Manager(map[, controls[, options]])

Parameters:

Parameter

Default value

Description

map*

Type: Map

Instance of the map.

controls

Type: String[]|IControl[]

The controls which should be initially placed on the map.

options

Type: Object

Manager options.

options.margin

10

Type: Number

Distance between adjacent controls and the indent from the edges of the map. Specified in pixels.

options.pane

Type: IPane

Container for controls.

options.states

['small', 'medium', 'large']

Type: String[]

The array of sizes, from smallest to largest.

* Mandatory parameter/option.

Fields

Name

Type

Description

events

event.Manager

Event manager.

options

option.Manager

Manager options.

state

data.Manager

Manager state. Names of fields that are available via the data.Manager.get method:

  • size - The state of the controls.

Methods

Name

Returns

Description

add(control[, options])

control.Manager

Adds a control to the manager.

each(callback, context)

control.Manager

Calls a handler function for all the controls.

get(index)

IControl|null

Returns the control, or null if no item has been found.

getChildElement(control)

vow.Promise

Returns the Promise object, which is confirmed by the HTML element that should hold the child element.

getContainer()

HTMLElement

Returns container where elements of the control will be added.

getMap()

Map

Returns reference to the map.

indexOf(childToFind)

Integer

Returns -1 if the control has not been found, or the index of the item in the manager.

remove(control)

control.Manager

Removing a control from the manager.

Fields details

events

{event.Manager} events

Event manager.

options

{option.Manager} options

Manager options.

state

{data.Manager} state

Manager state. Names of fields that are available via the data.Manager.get method:

  • size - The state of the controls.

Methods details

add

{control.Manager} add(control[, options])

Adds a control to the manager.

Returns self-reference.

Parameters:

Parameter

Default value

Description

control*

Type: IControl|String

Controls that are set by instances of classes that implement the IControl interface, or by keys.

Acceptable key values:

Also, you can specify one of the predefined sets of controls using special keys:

  • "smallMapDefaultSet" - Basic set of controls, optimized for small maps and mobile phone screens. It includes the following controls: "zoomControl", "searchControl", "typeSelector", "geolocationControl" and "fullscreenControl". All controls in this set are minimized to buttons with icons.
  • "mediumMapDefaultSet" - Basic set of controls, optimized for medium-sized maps and tablet screens. In addition to the basic set of controls (see above), this set includes "rulerControl" and "trafficControl".
  • "largeMapDefaultSet" - Basic set of controls, optimized for large maps and desktops. The "routeEditor" control is added to the set and the "fullScreen" control is removed from the set, compared to the "mediumMapDefaultSet".
  • "default" - Default set of controls, an alias for "mediumMapDefaultSet".

options

Type: Object

Control options.

options.float

"right"

Type: String

The side to which you want to align the control. Can take three values: "left", "right" or "none". If set to "left" or "right", the controls are arranged one by one, starting from the left or right edge of the map, respectively. If set to "none", the controls are positioned according to the values of the left, right, bottom and top options, relative to the boundaries of the map.

options.floatIndex

0

Type: Number

The priority of the control positioning. The element with highest priority is positioned closer to the map boundary that is specified in the float property. Does not work with float = "none".

options.position

Type: Object

Object describing the position of a control. If the position option is set, the float option value is automatically treated as "none".

options.position.bottom

'auto'

Type: Number|String

Position relative to the bottom edge of the map. Only works with float = none.

options.position.left

'auto'

Type: Number|String

Position relative to the left edge of the map. Only works with float = none.

options.position.right

'auto'

Type: Number|String

Position relative to the right edge of the map. Only works with float = none.

options.position.top

'auto'

Type: Number|String

Position relative to the top edge of the map. Only works with float = none.

* Mandatory parameter/option.

Example:

map.controls
    .add('zoomControl')
    .add('typeSelector');

each

{control.Manager} each(callback, context)

Calls a handler function for all the controls.

Returns self-reference.

Parameters:

Parameter

Default value

Description

callback*

Type: Function

Handler function. Receives a collection item as input. If the function returns the value "false," processing stops.

context*

Type: Object

Context of the invoked function.

* Mandatory parameter/option.

get

{IControl|null} get(index)

Returns the control, or null if no item has been found.

Parameters:

Parameter

Default value

Description

index*

Type: Number|String

The index of the desired element or key.

* Mandatory parameter/option.

getChildElement

{vow.Promise} getChildElement(control)

Returns the Promise object, which is confirmed by the HTML element that should hold the child element.

Parameters:

Parameter

Default value

Description

control*

Type: IControl

Control.

* Mandatory parameter/option.

getContainer

{HTMLElement} getContainer()

Returns container where elements of the control will be added.

getMap

{Map} getMap()

Returns reference to the map.

indexOf

{Integer} indexOf(childToFind)

Returns -1 if the control has not been found, or the index of the item in the manager.

Parameters:

Parameter

Default value

Description

childToFind*

Type: String

IControl

Control or its key.

* Mandatory parameter/option.

remove

{control.Manager} remove(control)

Removing a control from the manager.

Returns self-reference.

Parameters:

Parameter

Default value

Description

control*

Type: IControl|String

The deleted control or its key.

* Mandatory parameter/option.