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

Routing examples

Routing examples

Have a look at our functional examples to see how to implement search features with TomTomOnlineSDKRouting.

Speed up development by using our sample code snippets in your app. Try all of this out with the Maps SDK Examples app!

Travel modes

Allow your users to plan a route for different travel modes.

Sample use case: You want to check what travel mode (car or truck) gives you the best ETA for a trip from Amsterdam to Rotterdam.

TTOptionTravelMode travelMode = TTOptionTravelModeNone;
        travelMode = TTOptionTravelModeCar;
_query = [[[[TTRouteQueryBuilder createWithDest:COORDINATE_ROTTERDAM andOrig:COORDINATE_AMSTERDAM]
           withTravelMode:travelMode]
           withTraffic:NO]
          build];


image

Travel mode car.

image

Travel mode truck.

image

Travel mode pedestrian.

Route types

Allow your users to plan a route that will be the fastest, shortest, most thrilling or greenest.

Sample use case: You plan a trip from Amsterdam to Rotterdam and want to compare ETAs for different types of routes to choose the best fit for your preferences.

We can use types like:

  • Fastest

  • Shortest

  • Easiest

TTOptionTypeRoute routeType = TTOptionTypeRouteNone;
        routeType = TTOptionTypeRouteFastest;
_query = [[[[TTRouteQueryBuilder createWithDest:COORDINATE_ROTTERDAM andOrig:COORDINATE_AMSTERDAM]
           withRouteType:routeType]withTraffic:NO]
          build];

[_routePlanner planRouteWithQuery:_query];


image

Route type fastest.

image

Route type shortest.

image

Route type eco.

Route avoids

Allow your users to plan a route that avoids things like toll roads, motorways, ferries, unpaved roads, carpool lanes, and roads that they have already taken.

Sample use case: You plan a trip between the TomTom offices in Amsterdam and Oslo and you would like to check
how much time you gain by taking a ferry and how much more time it will take to drive if you don’t that motorways so you can take the best route for you.

You can use parameters like:

  • tollRoads

  • motorways

  • ferries

  • unpavedRoads

  • carpools

  • alreadyUsedRoads

TTOptionTypeAvoid avoidType = TTOptionTypeAvoidNone;
        avoidType = TTOptionTypeAvoidMotorways;
_query = [[[[TTRouteQueryBuilder createWithDest:COORDINATE_OSLO andOrig:COORDINATE_AMSTERDAM]
           withAvoidType:avoidType]withTraffic:NO]
          build];

[_routePlanner planRouteWithQuery:_query];


image

Route avoid motorways.

image

Route avoid toll roads.

image

Route avoid ferries.

Routing with waypoints

Allow your users to plan a route with up to 50 waypoints. Help your users to get the best route through all their stops in the optimal order.

Sample use case: You plan a trip from the TomTom office in Amsterdam to the office in Berlin.
There are a few places that you would like to visit on during the drive.
You would like to check if your preferred route is the best way to visit all of the places in the shortest time.
To do this, input the coordinates as waypoints and call the routing module using the withComputeBestOrder paramater.

In the example below the route is from Amsterdam to Berlin using withComputeBestOrder parameters.

_query = [[[[[TTRouteQueryBuilder createWithDest:COORDINATE_BERLIN andOrig:COORDINATE_AMSTERDAM]
                                        withWayPoints:waypoints]
                                 withComputeBestOrder:NO] withTraffic:NO]build];

[_routePlanner planRouteWithQuery:_query];


image

Initial order.

image

Best order.

Departure/Arrival time

Allow your users to plan a route for a specific arrival or departure time so they can use this information to adjust their commute plans.

Sample use case: You have a busy schedule and need to plan your day carefully.
You use the arrival at option to learn when you need to leave in order to be at a specific place at a specific time.
You then use depart at to know your ETA for your next appointment.

In the example below, you can see a sample implementation using the arrive at and depart at parameters for a trip from Amsterdam to Rotterdam.
The example uses a standard date/time picker widget.

self.query = [[[[TTRouteQueryBuilder createWithDest:COORDINATE_ROTTERDAM andOrig:COORDINATE_AMSTERDAM]
           withDepartAt: date]withTraffic:NO]
          build];
self.query = [[[[TTRouteQueryBuilder createWithDest:COORDINATE_ROTTERDAM andOrig:COORDINATE_AMSTERDAM]
           withArriveAt: date]
          withTraffic:NO]
          build];


image

One alternative.

image

Five alternatives.

Route alternatives

Allow your users to check different routing alternatives so they can choose the one they prefer.

Sample use case: You are preparing a road trip and you would like to see different route options
so you can choose one that is both optimal for your trip and suits your road trip preferences.

In the example below, you can see an implementation of alternative routes using a clickable route object.
Click on the route to get its ETA and the distance between its origin and destination.

_query = [[[[TTRouteQueryBuilder createWithDest:COORDINATE_ROTTERDAM andOrig:COORDINATE_AMSTERDAM]
          withMaxAlternatives:numberOfRoutes]
          withTraffic:NO]
          build];

Routing with language parameter

Allow your user to to get results in different languages so make your app international.
The language parameter determines the language of the guidance messages.
It does not affect proper nouns (the names of streets, plazas, etc.)

Sample use case: You are planning a journey and you want to have the list of
instructions in different languages.

To request a route using language parameter:

TTRouteQuery *query = [[[[TTRouteQueryBuilder createWithDest:COORDINATE_BERLIN andOrig:COORDINATE_AMSTERDAM] withInstructionsType:TTOptionInstructionsTypeText] withLanguage:language]build];
@property (nonatomic, strong) NSArray<TTInstruction *> *instructions;
- (void)route:(UNUSED_PARAM TTRoute *)route completedWithResult:(TTRouteResult *)result {
    TTSummary *summary = result.routes.firstObject.summary;
    self.instructions = result.routes.firstObject.guidance.instructions;

Maneuver list

Serve your users with list of maneuvers (driving instructions), providing turn by turn information for every maneuver.
You can get the maneuvers in different languages to internationalize your app.

Sample use case: You are planning a journey and you want to have the list of maneuvers so you can look them up en route.

In the example below, you can see an implementation of a maneuver list that is available in English, German, Spanish and French.

TTRouteQuery *query = [[[[TTRouteQueryBuilder createWithDest:COORDINATE_BERLIN andOrig:COORDINATE_AMSTERDAM] withInstructionsType:TTOptionInstructionsTypeText] withLanguage:language]build];


image

Maneuver list English.

image

Maneuver list Spanish.

Unresolved directive in index.adoc - include::9ConsuptionModel[]

Unresolved directive in index.adoc - include::10SupportingPoints[]

Reachable range

The Reachable Range component calculates a set of locations that can be reached from the origin point. It optimizes for routes with a given route-type (e.g. fastest, eco, etc) but limits the range for the given budget and consumption parameters.
It uses Calculate Reachable Range API so you can find all details in the service documentation.

Sample use case: You are preparing to a trip and you would like to check how far you can drive on your battery or tank, or within specific time limit so you plan your journey.

The example below shows a number of points that are reachable based on one of specified model for:
* Combustion engine
* Electric engine
* Time-2h limit on an electric car (time budget model is available for both electric and combustion engines)

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

To request a reachable range create a ReachableRangeQuery:

query = [[[[[[[[[[[[[TTReachableRangeQueryBuilder createWithCenterLocation:COORDINATE_AMSTERDAM] withSpeedConsumptionInLitersPairs:consumption count:1]
                 withVehicleWeight:1600]
                withCurrentFuelInLiters:43]
               withFuelEnergyDensityInMJoulesPerLiter:34.2]
              withCurrentAuxiliaryPowerInLitersPerHour:1.7]
             withAccelerationEfficiency:0.33]
            withDecelerationEfficiency:0.33]
           withUphillEfficiency:0.33]
          withDownhillEfficiency:0.33]
         withVehicleEngineType:TTOptionVehicleEngineTypeCombustion]
        withFuelBudgetInLiters:5]
    build];

The result can be observed with TTReachableRangeDelegate:

- (void)reachableRange:(TTReachableRange *)range completedWithResult:(TTReachableRangeResponse *)response {
}

- (void)reachableRange:(TTReachableRange *)range completedWithResponseError:(TTResponseError *)responseError {
}


image

Fuel budget: 5 liters

image

Energy budget: 5 kWh

image

Time budget: 2h

You can use the output of the returned set of locations for other interacting use cases e.g. searching for places on the route to one (many) reachable point(s) with Search along the route or within the polygon boundaries with Geometry search features of Maps SDK.