Routing

Overview

The Router is a service for building routes on the map. The service allows you to automatically calculate a route between specified points and get information about the route, such as the distance of the route or the estimated travel time. You can set routes with or without traffic allowances.

The following types of routing are available:

  • driving
  • walking
  • public transit
  • biking

The API takes the specified points and builds several optimal routes. The fastest route is set as the active route. It is displayed on the map in purple. Alternative routes are gray. Users can switch between routes with a click.

Attention. Routing requests are fee-based.

Ways to set a route

You can set a route on the map in the following ways:

Method Description

In the routing panel

Interface control for working with routes. Users can set the start and ending points of a route, select a routing type, or remove a route from the map.

The routing panel allows you to programmatically set route points and select a routing type.

Advantages
  • Convenient interface: users choose their own route.
  • Build routes that allow ordering a taxi. Details

Disadvantages

  • Doesn't support intermediary points — you can only set routes with two endpoints.

At the code level, using the multiRouter.MultiRoute class

Routing control at the level of program code.

Advantages
  • Allows you to build multi-stop routes with an unlimited number of points.
  • Allows you to build bike routes.

Disadvantages

  • More difficult to implement.

Basic concepts

Multiroute — A basic object for working with routing. It contains information about created routes: the geometry, pixel data, travel time, and so on. The multiroute processes this data and creates a view to display the routes on the map.

Active route — The selected route. It is displayed on the map in purple. By default, the fastest available route is selected as the active route.

Waypoint (or stopping point) — A point on the route to stop at. The start and ending points are also considered waypoints. On the map, waypoints are marked with letters, such as “A”, “B”, “C”.

Throughpoint — An intermediary point that the route must go through, but does not imply a stop. Throughpoints are only available for driving routes.

Path — The route line that connects waypoints. In the image below, the route has two paths. The first path is between points “A” and “B”, and the second path is between points “B” and “C”. Routes that are built via the routing panel always have one path.

Segment — A section of the route between:
  • Waypoints or throughpoints.
  • Points where the direction of travel may change (a fork, entrance, exit, turn, U-turn, or intersection).
  • Points where the type of route section changes. For example, the point where a “walking” segment changes to a “bus” segment.