Documentation
Reference
2.1.50 (current version)
collection
interactivityModel
Interfaces
2.1.51 (release candidate)
collection
interactivityModel
Interfaces

behavior.RouteEditor

Extends IBehavior.

"Route editor" behavior.

Constructor | Fields | Events | Methods

Constructor

behavior.RouteEditor()

Fields

NameTypeDescription
eventsIEventManager

Event manager.

Inherited from IEventEmitter.

optionsIOptionManager

Options manager.

Inherited from ICustomizable.

Events

NameDescription
disable

Disabling behaviors.

Inherited from IBehavior.

enable

Enabling behaviors.

Inherited from IBehavior.

optionschange

Change to the object options.

Inherited from ICustomizable.

parentchange

The parent object reference changed.

Data fields:

  • oldParent - Old parent.
  • newParent - New parent.

Inherited from IChild.

routechange

A changed route event resulting from calling the setState method or enabling/disabling behaviors. You can get the old and new routes from the properties of the "oldRoute" and "newRoute" events, respectively.

Methods

NameReturnsDescription
disable()

Disables the behavior.

Inherited from IBehavior.

enable()

Enables the behavior.

Inherited from IBehavior.

getParent()

IControlParent|null

Returns link to the parent object, or null if the parent element was not set.

Inherited from IChildOnMap.

getRoute()

router.Route

Returns route.

getState()

String

Returns the current state of the route editor in encoded format.

isEnabled()

Boolean

Checks whether the behavior is enabled.

Inherited from IBehavior.

setParent(parent)

IChildOnMap

Sets the parent object. If the null value is passed, the manager element will only be deleted from the current parent object.

Inherited from IChildOnMap.

setState(state)

Restores the state of the route editor from the encoded string. When setting a new route, the "routechange" event is called.

Events details

routechange

A changed route event resulting from calling the setState method or enabling/disabling behaviors. You can get the old and new routes from the properties of the "oldRoute" and "newRoute" events, respectively.

Methods details

getRoute

{router.Route} getRoute()

Returns route.

getState

{String} getState()

Returns the current state of the route editor in encoded format.

setState

{} setState(state)

Restores the state of the route editor from the encoded string. When setting a new route, the "routechange" event is called.

Parameters:

ParameterDefault valueDescription
state*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: String|null

Encoded state of the route editor. The state is set in the following format: rt=point1~point2~point3~point4...&via=via-point-indexes For example, if the encoded string looks like this: "rt=50,30~42,35~45,32~40,30&via=1,2", it means the waypoints on the route should be "50,30" and "40,30", and the midpoints are "42,35" and "45,32". If the "via" parameter is omitted, the route will consist solely of waypoints.

* Mandatory parameter/option.

Example:

var behavior = map.behaviors.get('routeEditor');
behavior.events.add('routechange', function (e) {
   var newRoute = e.get('newRoute');
   alert(newRoute.getLength()); // length of the new route
   setTimeout(function () {
       // deleting the route
       behavior.setState(null);
   })
});
behavior.setState('rt=55.874872,37.562677~55.92517867214157,37.62725433916199~55.920011490602526,37.6629269628905&via=1');