Sorry, you need to enable JavaScript to visit this website.

Batch routing

Batch routing

Allow your users to send multiple synchronous routing requests with Batch Routing components. You can mix different
types of routing requests to compare them in an easy way.

Batch Routing components described use Online Batch Routing API
so you can find all details about it in the service documentation.

Sample use case: You are preparing to a trip and you would like to choose the most optimal route for your travel.
You would like to compare the ETA and distances for routes depending on travel modes, route types or avoids.

Also, you can adjust the batch request with other parameters described in Online Batch Routing API
or JavaDocs of this SDK under Api reference section.

The example below shows multiple routes requested in the batch. Each example sends three requests in one batch.
All examples allow a user to compare routes visually on the map, their ETAs and distances by clicking on a chosen route.

  • Travel mode example shows three routes: the route by car, the route by truck and the route as a pedestrian.

  • Route type example shows three routes: the fastest route, the shortest route and the most eco route.

  • Avoids example shows three routes: the avoid-motorways route, the avoid-ferries route and the avoid-toll roads.

Use the code sample below for implementing a similar use case.

To request a batch query create a TTBatchRouteQuery:


let batchQuery = TTBatchRouteQueryBuilder.createRouteQuery(queryCar)
TTBatchRouteQuery *batchQuery =
    [[[[TTBatchRouteQueryBuilder createRouteQuery:queryCar]
        addRouteQuery:queryTruck] addRouteQuery:queryPedestrain] build];


and pass it to the routing API:


batchRoute = TTBatchRoute()
batchRoute.delegate = self
batchRoute.batchRoute(with: batchQuery)
self.batchRoute = [[TTBatchRoute alloc] init];
self.batchRoute.delegate = self;
[self.batchRoute batchRouteWithQuery:batchQuery];


Setup of the common params for batch routing query:


let queryPedestrain = TTRouteQueryBuilder.create(withDest: TTCoordinate.ROTTERDAM(), andOrig: TTCoordinate.AMSTERDAM())
TTRouteQuery *queryPedestrain = [[[[[TTRouteQueryBuilder
    createWithDest:[TTCoordinate ROTTERDAM]
           andOrig:[TTCoordinate AMSTERDAM]] withComputeBestOrder:YES]
    withTraffic:YES] withTravelMode:TTOptionTravelModePedestrian] build];


The result can be observed with TTBatchRouteResponseDelegate:


func batch(_: TTBatchRoute, completedWith response: TTBatchRouteResponse) {
func batch(_: TTBatchRoute, failedWithError responseError: TTResponseError) {
func visitRoute(_ response: TTRouteResult) {
    let mapRoute = TTMapRoute(coordinatesData: response.routes.first!,
                              with: TTMapRouteStyle.defaultInactive(),
                              imageStart: TTMapRoute.defaultImageDeparture(),
                              imageEnd: TTMapRoute.defaultImageDestination())
    mapRoute.extraData = response.routes.first?.summary
- (void)batch:(TTBatchRoute *_Nonnull)route
    completedWithResponse:(TTBatchRouteResponse *_Nonnull)response {
  [response visit:self];
- (void)batch:(TTBatchRoute *_Nonnull)route
    failedWithError:(TTResponseError *_Nonnull)responseError {
- (void)visitRoute:(TTRouteResult *)response {
  TTMapRoute *mapRoute =
      [TTMapRoute routeWithCoordinatesData:response.routes.firstObject
  mapRoute.extraData = response.routes.firstObject.summary;
  [self.mapView.routeManager addRoute:mapRoute];
  [self.progress hide];
  [self.mapView.routeManager showAllRoutesOverview];



Travel modes: car, truck, pedestrian


Route type: fastest, shortest, eco


Avoids: motorways, ferries, toll roads

You can select route and get information about ETA and distances.

You are here