Documentation
Reference
2.1.50 (current version)
collection
interactivityModel
Interfaces

multiRouter.MultiRoute

Extends IGeoObject.

Multi-stop route on the map. Allows to display the route on the map along with one or more alternatives. Provides the interface for selecting the active route.

Constructor | Fields | Events | Methods

Constructor

multiRouter.MultiRoute(model[, options])

Creates a multi-stop route on the map.

Parameters:

ParameterDefault valueDescription
model *
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: multiRouter.MultiRouteModel|IMultiRouteModelJson

The data model of a multi-stop route, or the model description object. If you pass a description object, the model (which is based on it) is created automatically.

options

Type: Object

Multi-stop route options. To define options for the parts of a multi-stop route, the following prefixes are available:

  • wayPoint - Waypoint options.
  • wayPointStart - Display options for the starting waypoint.
  • wayPointFinish - Display options for the end waypoint.
  • viaPoint - Throughpoint options.
  • pin - Options for point markers on the route.
  • editor - Options for the multi-stop route editor (see multiRouter.Editor).
Options of individual routes within a multi-stop route are specified using the following prefixes:
  • route - Options for routes, including inactive ones.
  • routeActive - Options for the active route.
Note that options specified with the "routeActive" prefix have a higher priority than the options with the "route" prefix. To define options for the parts of public transport routes, use the following prefixes:
  • routeMarker - Options for route segment markers.
  • routeWalkMarker - Options for markers of walking segments on the route.
  • routeTransferMarker - Options for transfer segment markers.
  • routeTransportMarker - Options for transit segment markers on the route.
  • routeWalkSegment - Options for walking segment lines on the route.
  • routeTransferSegment - Options for transfer segment lines.
  • routeTransportSegment - Options for transit segment lines on the route.
  • routePedestrianSegment - Options for the pedestrian route segment lines.
These prefixes are also available in the "routeActive*" version.

options.activeRouteAutoSelection true

Type: Boolean

After the data is refreshed, automatically use the route with the least travel time as the active route.

options.boundsAutoApply false

Type: Boolean

When adding a multi-stop route to the map, you can automatically set the center and the zoom level so that the multi-stop route is entirely visible.

options.dragUpdateInterval

Type: String|Number

Time interval of rebuilding the route while reference points are being dragged. Can be set in milliseconds, or the optimal value can be calculated automatically. The value of this option is translated to the IMultiRouteParams.requestSendInterval parameter of the multi-stop route.

options.preventDragUpdate false

Type: Boolean

Allows to disable the route update while reference points are being dragged.

options.useMapMargin true

Type: Boolean

Whether to account for map margins map.margin.Manager.

options.zoomMargin 0

Type: Number|Number[]

Offset from the map viewport borders when changing the zoom level. If a single number is set, it is applied to each side. If two numbers are set, they are the horizontal and vertical margins, respectively. If an array of four numbers is set, they are the top, right, bottom, and left margins. When the "useMapMargin" option is enabled, the "zoomMargin" value is combined with the values that were calculated in the margins manager map.margin.Manager.

* Mandatory parameter/option.

Example:

// Creating a multi-stop route and adding it to the map.
var multiRoute = new ymaps.multiRouter.MultiRoute({
    referencePoints: ['Moscow, Leninsky Prospekt, Moscow, Kulakov pereulok'],
}, {
    editorDrawOver: false,
    wayPointDraggable: true,
    viaPointDraggable: true,
    // Setting a custom design for multi-stop route lines.
    routeStrokeColor: "000088",
    routeActiveStrokeColor: "ff0000",
    pinIconFillColor: "ff0000",
    boundsAutoApply: true,
    zoomMargin: 30
});
myMap.geoObjects.add(multiRoute);

Fields

NameTypeDescription
boundsautoapply

The event occurs at the time of setting the map center and its zoom level for optimal display of the multi-stop route. Also see the description of the boundsAutoApply option. Instance of the Event class.

editormultiRouter.EditorAddon

Multi-stop route editor.

eventsIEventManager

Event manager.

Inherited from IDomEventEmitter.

geometryIGeometry|null

Geo object geometry.

Inherited from IGeoObject.

modelmultiRouter.MultiRouteModel

The data model of a multi-stop route.

optionsIOptionManager

Options manager.

Inherited from ICustomizable.

propertiesIDataManager

Geo object data.

Inherited from IGeoObject.

stateIDataManager

State of the geo object.

Inherited from IGeoObject.

Events

NameDescription
activeroutechange

Change to the active route. Instance of the Event class. Names of fields that are available via the Event.get method:

  • oldActiveRoute: multiRouter.driving.Route|multiRouter.masstransit.Route|null - previous active route.

boundschange

Changing coordinates of the geographical area covering the multi-stop route. Instance of the Event class.

click

Single left-click on the object. When using, keep in mind that mouse events are emulated when a touch screen is used. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

contextmenu

Calls the element's context menu. When using, keep in mind that mouse events are emulated when a touch screen is used. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

dblclick

Double left-click on the object. When using, keep in mind that mouse events are emulated when a touch screen is used. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

geometrychange

Change to the geo object geometry. Instance of the Event class. Names of fields that are available via the Event.get method:

  • originalEvent: IEvent - Original event of the geometry.

Inherited from IGeoObject.

mapchange

Map reference changed. Data fields:

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

Inherited from IParentOnMap.

mousedown

Pressing the mouse button over the object. When using, keep in mind that mouse events are emulated when a touch screen is used. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

mouseenter

Pointing the cursor at the object. When using, keep in mind that mouse events are emulated when a touch screen is used. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

mouseleave

Moving the cursor off of the object. When using, keep in mind that mouse events are emulated when a touch screen is used. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

mousemove

Moving the cursor over the object. When using, keep in mind that mouse events are emulated when a touch screen is used. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

mouseup

Letting go of the mouse button over an object. When using, keep in mind that mouse events are emulated when a touch screen is used. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

multitouchend

End of multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface.

Inherited from IDomEventEmitter.

multitouchmove

Repeating event during multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface with information about touches. Defines the touches property, which contains a list of touches. Every touch is described by an object that contains the following fields:

  • clientX - X coordinate of the touch relative to the viewable area of the browser.
  • clientY - Y coordinate of the touch relative to the viewable area of the browser.
  • pageX - X coordinate of the touch relative to the beginning of the document.
  • pageY - Y coordinate of the touch relative to the beginning of the document.

Inherited from IDomEventEmitter.

multitouchstart

Start of multitouch. This event is only available on devices that support multitouch. Returns an implementation of the IMultiTouchEvent interface with information about touches. Defines the touches property, which contains a list of touches. Every touch is described by an object that contains the following fields:

  • clientX - X coordinate of the touch relative to the viewable area of the browser.
  • clientY - Y coordinate of the touch relative to the viewable area of the browser.
  • pageX - X coordinate of the touch relative to the beginning of the document.
  • pageY - Y coordinate of the touch relative to the beginning of the document.

Inherited from IDomEventEmitter.

optionschange

Change to the object options.

Inherited from ICustomizable.

overlaychange

Change to the geo object overlay. Instance of the Event class. Names of fields that are available via the Event.get method:

  • overlay: IOverlay|null - Reference to the overlay.
  • oldOverlay: IOverlay|null - Previous overlay of the geo object.

Inherited from IGeoObject.

parentchange

The parent object reference changed.

Data fields:

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

Inherited from IChild.

pixelboundschange

Changing pixel coordinates of the area covering the multi-stop route. Instance of the Event class.

propertieschange

Change to the geo object data. Instance of the Event class. Names of fields that are available via the Event.get method:

  • originalEvent: IEvent - Original event of the data manager.

Inherited from IGeoObject.

update

Updating the multi-stop route. Instance of the Event class.

wheel

Mouse wheel scrolling. When using, keep in mind that mouse events are emulated when a touch screen is used. More information is available in domEvent.manager.

Inherited from IDomEventEmitter.

Methods

NameReturnsDescription
getActiveRoute()

multiRouter.driving.Route|multiRouter.masstransit.Route|null

Returns active route.

getBounds()

Number[][]|null

Returns the geographical coordinates of the area covering the multi-stop route.

getMap()

Map

Returns reference to the map.

Inherited from IParentOnMap.

getOverlay()

vow.Promise

Returns the promise object, which is confirmed by the overlay object at the time it is actually created, or is rejected with an appropriate error message.

Inherited from IGeoObject.

getOverlaySync()

IOverlay|null

The method provides synchronous access to the overlay.

Inherited from IGeoObject.

getParent()

IControlParent|null

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

Inherited from IChildOnMap.

getPixelBounds()

Number[][]|null

Returns the global pixel coordinates of the area covering the multi-stop route.

getRoutes()

GeoObjectCollection

Returns child collection of individual routes on the multi-stop route.

getViaPoints()

GeoObjectCollection

Returns child collection of throughpoints for the multi-stop route.

getWayPoints()

GeoObjectCollection

Returns child collection of waypoints for the multi-stop route.

setActiveRoute(route)

Sets the active route. The previous active route is deactivated and the multiRouter.MultiRoute.activeroutechange event is generated.

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.

Fields details

boundsautoapply

boundsautoapply

The event occurs at the time of setting the map center and its zoom level for optimal display of the multi-stop route. Also see the description of the boundsAutoApply option. Instance of the Event class.

editor

Multi-stop route editor.

Example:

// Start of route editing.
ymaps.route(['Moscow', 'Petersburg'], { multiRoute: true })
    .done(function (multiRoute) {
        myMap.geoObjects.add(multiRoute);
        multiRoute.editor.start({
            addWayPoints: true,
            removeWayPoints: true
        });
        // ...
        // End of route editing.
        multiRoute.editor.stop();
    });

model

The data model of a multi-stop route.

Events details

activeroutechange

Change to the active route. Instance of the Event class. Names of fields that are available via the Event.get method:

  • oldActiveRoute: multiRouter.driving.Route|multiRouter.masstransit.Route|null - previous active route.

boundschange

Changing coordinates of the geographical area covering the multi-stop route. Instance of the Event class.

pixelboundschange

Changing pixel coordinates of the area covering the multi-stop route. Instance of the Event class.

update

Updating the multi-stop route. Instance of the Event class.

Methods details

getActiveRoute

Returns active route.

getBounds

{Number[][]|null} getBounds()

Returns the geographical coordinates of the area covering the multi-stop route.

getPixelBounds

{Number[][]|null} getPixelBounds()

Returns the global pixel coordinates of the area covering the multi-stop route.

getRoutes

{GeoObjectCollection} getRoutes()

Returns child collection of individual routes on the multi-stop route.

getViaPoints

{GeoObjectCollection} getViaPoints()

Returns child collection of throughpoints for the multi-stop route.

getWayPoints

{GeoObjectCollection} getWayPoints()

Returns child collection of waypoints for the multi-stop route.

setActiveRoute

{} setActiveRoute(route)

Sets the active route. The previous active route is deactivated and the multiRouter.MultiRoute.activeroutechange event is generated.

Parameters:

ParameterDefault valueDescription
route*
[no-highlight[

* Mandatory parameter/option.

]no-highlight]

Type: multiRouter.driving.Route|multiRouter.masstransit.Route|null

Route to activate.

* Mandatory parameter/option.