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:

Parameter Default value Description
map *

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

Name Type Description
events IEventManager

Event manager.

Inherited from IEventEmitter.

options IOptionManager

Options manager.

Inherited from ICustomizable.

Events

Name Description
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

Name Returns Description
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:

Parameter Default value Description
behaviors *

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:

Parameter Default value Description
behaviors *

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:

Parameter Default value Description
behaviorName *

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:

Parameter Default value Description
behaviorName *

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');
}