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

multiRouter.MultiRouteModel

Extends IEventEmitter.

The data model of a multi-stop route.

Constructor | Fields | Events | Methods

Constructor

multiRouter.MultiRouteModel(referencePoints[, params])

Creates the data model of a multi-stop route.

Parameters:

ParameterDefault valueDescription
referencePoints *
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: IMultiRouteReferencePoint[]

The description of the reference points on the multi-stop route.

params

Type: IMultiRouteParams

Routing options.

* Mandatory parameter/option.

Example:

// Creating a model of the multi-stop route.
var multiRouteModel = new ymaps.multiRouter.MultiRouteModel(['Moscow', 'Tver', 'Peterburg'], {
    avoidTrafficJams: true,
    viaIndexes: [1]
});

// Creating a representation of a multi-stop route based on the model.
var multiRouteView = new ymaps.multiRouter.MultiRoute(multiRouteModel);
myMap.geoObjects.add(multiRouteView);

// Subscribing to the events of the multi-stop route model.
multiRouteView.model.events
    .add("requestsuccess", function (event) {
        var routes = event.get("target").getRoutes();
        console.log("Found routes: " + routes.length);
        for (var i = 0, l = routes.length; i < l; i++) {
            console.log("Route length " + (i + 1) + ": " + routes[i].properties.get("distance").text);
        }
    })
    .add("requestfail", function (event) {
        console.log("Error: " + event.get("error").message);
    });

Fields

NameTypeDescription
eventsIEventManager

Event manager.

Inherited from IEventEmitter.

propertiesdata.Manager

Multi-stop route data.

Events

NameDescription
requestcancel

The data request has been canceled. Instance of the Event class. Names of fields that are available via the Event.get method:

  • referencePoints: Object[] - Array describing the set of reference points.
  • params: Object - Routing options.

requestchange

The reference data model of a multi-stop route (anchor points or routing options) has been changed. The result is a new data request to the routing service. Instance of the Event class. Names of fields that are available via the Event.get method:

  • referencePoints: Object[] - Array describing the set of reference points.
  • params: Object - Routing parameters.
  • oldReferencePoints: Object[] - Array describing the previous array of reference points.
  • oldParams: Object - Previous routing options.

requestfail

The request for data has failed. Instance of the Event class. Names of fields that are available via the Event.get method:

  • error: Error - error object.

requestsend

A new request for the multi-stop route data model has been sent. Instance of the Event class. Names of fields that are available via the Event.get method:

  • referencePoints: Object[] - Array describing the set of reference points.
  • params: Object - Routing options.

requestsuccess

The request for data has completed successfully and the data model has been updated. Instance of the Event class. Names of fields that are available via the Event.get method:

  • init: Boolean - Indicates an initialization request.
  • rough: Boolean - Flag for whether it is an intermediate request (used to optimize the size of the server response when editing a route).
  • wayPointsChange: Boolean - Flag for whether the set of waypoints is changed.
  • viaPointsChange: Boolean - Flag for whether the set of throughpoints is changed.
  • routesChange: Boolean - Flag for whether the set of routes is changed.

Methods

NameReturnsDescription
destroy()

Destroys a model.

getAllPoints()

(multiRouter.WayPointModel|multiRouter.ViaPointModel)[]

Returns the combined array of models of throughpoints and waypoints, in the same order as the corresponding reference points.

getJson()

Object

Returns JSON data for the multi-stop route model.

getParams()

IMultiRouteParams

Returns the object with the current values of routing options.

getPoints()

(multiRouter.WayPointModel|multiRouter.ViaPointModel)[]

Deprecated name of the multiRouter.MultiRouteModel.getAllPoints method. Not recommended for use.

getReferencePointIndexes()

Object

Returns an object containing the following data fields:

  • way: Integer[] - Indexes of reference points corresponding to the set of the model's waypoints.
  • via: Integer[] - Indexes of reference points corresponding to the set of the model's throughpoints.
.

getReferencePoints()

IMultiRouteReferencePoint[]

Returns array of reference points on the multi-stop route.

getRoutes()

multiRouter.driving.RouteModel[]|multiRouter.masstransit.RouteModel[]

Returns an array of models for child routes.

getViaPoints()

multiRouter.ViaPointModel[]

Returns an array of models for child throughpoints.

getWayPoints()

multiRouter.WayPointModel[]

Returns an array of models for child waypoints.

setParams(params[, extend[, clearRequests]])

Sets routing options.

setReferencePoints(referencePoints[, viaIndexes[, clearRequests]])

Sets the reference points on the multi-stop route.

Fields details

properties

{data.Manager} properties

Multi-stop route data.

Events details

requestcancel

The data request has been canceled. Instance of the Event class. Names of fields that are available via the Event.get method:

  • referencePoints: Object[] - Array describing the set of reference points.
  • params: Object - Routing options.

requestchange

The reference data model of a multi-stop route (anchor points or routing options) has been changed. The result is a new data request to the routing service. Instance of the Event class. Names of fields that are available via the Event.get method:

  • referencePoints: Object[] - Array describing the set of reference points.
  • params: Object - Routing parameters.
  • oldReferencePoints: Object[] - Array describing the previous array of reference points.
  • oldParams: Object - Previous routing options.

requestfail

The request for data has failed. Instance of the Event class. Names of fields that are available via the Event.get method:

  • error: Error - error object.

requestsend

A new request for the multi-stop route data model has been sent. Instance of the Event class. Names of fields that are available via the Event.get method:

  • referencePoints: Object[] - Array describing the set of reference points.
  • params: Object - Routing options.

requestsuccess

The request for data has completed successfully and the data model has been updated. Instance of the Event class. Names of fields that are available via the Event.get method:

  • init: Boolean - Indicates an initialization request.
  • rough: Boolean - Flag for whether it is an intermediate request (used to optimize the size of the server response when editing a route).
  • wayPointsChange: Boolean - Flag for whether the set of waypoints is changed.
  • viaPointsChange: Boolean - Flag for whether the set of throughpoints is changed.
  • routesChange: Boolean - Flag for whether the set of routes is changed.

Methods details

destroy

{} destroy()

Destroys a model.

getAllPoints

Returns the combined array of models of throughpoints and waypoints, in the same order as the corresponding reference points.

getJson

{Object} getJson()

Returns JSON data for the multi-stop route model.

getParams

{IMultiRouteParams} getParams()

Returns the object with the current values of routing options.

getPoints

Deprecated name of the multiRouter.MultiRouteModel.getAllPoints method. Not recommended for use.

Returns the combined array of models of throughpoints and waypoints, in the same order as the corresponding reference points.

getReferencePointIndexes

{Object} getReferencePointIndexes()

Returns an object containing the following data fields:

  • way: Integer[] - Indexes of reference points corresponding to the set of the model's waypoints.
  • via: Integer[] - Indexes of reference points corresponding to the set of the model's throughpoints.
.

getReferencePoints

{IMultiRouteReferencePoint[]} getReferencePoints()

Returns array of reference points on the multi-stop route.

getRoutes

{multiRouter.driving.RouteModel[]|multiRouter.masstransit.RouteModel[]} getRoutes()

Returns an array of models for child routes.

getViaPoints

{multiRouter.ViaPointModel[]} getViaPoints()

Returns an array of models for child throughpoints.

getWayPoints

{multiRouter.WayPointModel[]} getWayPoints()

Returns an array of models for child waypoints.

setParams

{} setParams(params[, extend[, clearRequests]])

Sets routing options.

Parameters:

ParameterDefault valueDescription
params*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: IMultiRouteParams

Routing options.

extend false

Type: Boolean

Allows you to change only the specified set of parameters keeping all the rest of the values the same.

clearRequests false

Type: Boolean

Allows you to clear the queue of previous requests to the server.

* Mandatory parameter/option.

setReferencePoints

{} setReferencePoints(referencePoints[, viaIndexes[, clearRequests]])

Sets the reference points on the multi-stop route.

Parameters:

ParameterDefault valueDescription
referencePoints*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: IMultiRouteReferencePoint[]

Array of reference points.

viaIndexes

Type: Integer[]

Indexes of throughpoints in the array of reference points.

clearRequests false

Type: Boolean

Allows you to clear the queue of previous requests to the server.

* Mandatory parameter/option.