Static function.

Plots a route through the specified points.

Returns a promise object that is confirmed by the route object router.Route, or the multiroute object multiRouter.MultiRoute, depending on the value of the multiRoute parameter. If an error occurs, the promise object is rejected.

{ vow.Promise } route(points[, params])


Parameter Default value Description
points *

Type: Object[]

Array of points that the route should go through. Each point can be set by a string containing the address, an array of the coordinates, and a JSON object with the following fields:
  • type: String - Type of point. The 'wayPoint' value sets the route waypoint. Use the "viaPoint" value to define a throughpoint, i.e. a point that must be driven through without stopping.
  • point: Number[]|String - Array of the coordinates of a point, or its address as a string.

Type: Object

Routing options.

params.avoidTrafficJams false

Type: Boolean

Enables constructing a route with consideration for traffic. When using the options, keep in mind that it is not always possible to detour around traffic jams.


Type: Number[][]

Area on the map where the objects being searched for are presumably located. This is used if the route points are set using the mailing address instead of coordinates.

params.mapStateAutoApply false

Type: Boolean

Flag that allows to automatically set the center and map zoom so that the route will be entirely visible.

params.multiRoute false

Type: Boolean

Allows to construct multiroutes.

params.reverseGeocoding false

Type: Boolean

Whether to use reverse geocoding for points specified as coordinates.

params.routingMode "auto"

Type: String

Routing type. Accepts one of three string values:
  • "auto" - Driving route.
  • "masstransit" - Routing using public transit. Only for multiroutes (the multiRoute option must be set to true).
  • "pedestrian" - Walking route. Only for multiroutes (the multiRoute option must be set to true).

Type: String

Defines how to interpret the coordinates in the request. This is used if the route points are set using coordinates, and not the mailing address.

params.strictBounds false

Type: Boolean

Search only inside the area defined by the "boundedBy" option.

params.useMapMargin true

Type: Boolean

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

params.viaIndexes []

Type: Integer[]

Indexes of the multiroute throughpoints.

params.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" parameter is enabled, the "zoomMargin" value is combined with the values that were calculated in the margins manager map.margin.Manager.

* Mandatory parameter/option.



// Building the route from Korolev to Krasnogorsk via Khimki and Mytischi,
// where Mytischi is a throughpoint. Setting coordinates for Krasnogorsk.
    { type: 'viaPoint', point: 'Mytischi' },
    { type: 'wayPoint', point: [55.811511, 37.312518] }
], {
    mapStateAutoApply: true
}).then(function (route) {
        // the balloon only shows information about the travel time with traffic
        balloonContentLayout: ymaps.templateLayoutFactory.createClass('{{ properties.humanJamsTime }}'),
        // you can make settings for route graphics
        strokeColor: '0000ffff',
        opacity: 0.9
    // adding the route to the map


// Building a multiroute and adding it to the map using autoscaling.
ymaps.route(['Southern Butovo', 'Moscow, metro Park Kultury'], {
    multiRoute: true
}).done(function (route) {
    route.options.set("mapStateAutoApply", true);
}, function (err) {
    throw err;
}, this);