Documentation
Reference
2.1.50 (current version)
collection
interactivityModel
Interfaces

map.behavior.Manager

Extends ICustomizable, IEventEmitter, IParentOnMap.

Map behaviors manager. Allows to enable and disable behaviors. Each map already has its own behavior manager, available as map.behaviors. Don't instantiate new instances of this class unless necessary

See Map.behaviors

Constructor | Fields | Events | Methods

Constructor

map.behavior.Manager(map[, behaviors[, options]])

Parameters:

ParameterDefault valueDescription
map *
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: Map

Map.

behaviors

Type: String[][]|String[]

List of map behaviors that are immediately enabled when a map is created. By default - "drag", "dblClickZoom" and "rightMouseButtonMagnifier" for desktop browsers; "drag", "dblClickZoom" and "multiTouch" for mobile browsers.

Acceptable key values:

You can add and remove behavior classes via the behaviors storage behavior.storage.

options

Type: Object

Behavior options. The following options can be set:

* Mandatory parameter/option.

Fields

NameTypeDescription
eventsIEventManager

Event manager.

Inherited from IEventEmitter.

optionsIOptionManager

Options manager.

Inherited from ICustomizable.

Events

NameDescription
mapchange

Map reference changed. Data fields:

  • oldMap - Old map.
  • newMap - New map.

Inherited from IParentOnMap.

optionschange

Change to the object options.

Inherited from ICustomizable.

Methods

NameReturnsDescription
disable(behaviors)

map.behavior.Manager

Disables behaviors on the map.

enable(behaviors)

map.behavior.Manager

Enables behaviors on the map.

get(behaviorName)

IBehavior

Returns instance of the behavior by the key.

getMap()

Map

Returns reference to the map.

Inherited from IParentOnMap.

isEnabled(behaviorName)

Boolean

Checks whether a behavior is currently enabled.

Methods details

disable

Disables behaviors on the map.

Returns self-reference.

Parameters:

ParameterDefault valueDescription
behaviors*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: String[][]|String[]

List of behaviors that can be disabled.

* Mandatory parameter/option.

Example:

myMap.behaviors.disable('drag');

enable

Enables behaviors on the map.

Returns self-reference.

Parameters:

ParameterDefault valueDescription
behaviors*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: String[][]|String[]

List of behaviors that can be enabled.

* Mandatory parameter/option.

Example:

myMap.behaviors.enable(['ruler', 'multiTouch']);

get

Returns instance of the behavior by the key.

Parameters:

ParameterDefault valueDescription
behaviorName*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: String

Name of the behavior.

* Mandatory parameter/option.

Example:

myMap.behaviors.get('drag');

isEnabled

{Boolean} isEnabled(behaviorName)

Checks whether a behavior is currently enabled.

Returns true if the behavior is enabled, otherwise false.

Parameters:

ParameterDefault valueDescription
behaviorName*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: String

Behavior ID.

* Mandatory parameter/option.

Example:

// If the "drag" behavior is disabled, we enable it
if (!(myMap.behaviors.isEnabled('drag'))) {
    myMap.behaviors.enable('drag');
}