Quickstart
The Routing module provides the tools to integrate the TomTom Routing API into an Android application. It is used to calculate a route between an origin and a destination, using a range of options and taking traffic into account. Read more about TomTom’s Routing parameters.
Once planned, routes can be displayed on the map or used for turn by turn navigation.
Project setup
Configure the project as described in the Project setup guide.
Then add the following dependencies to the build.gradle.kts
file of your application module and synchronize the project.
implementation("com.tomtom.sdk.routing:route-planner-online:1.25.6")
After synchronizing the project, you can initialize the RoutePlanner
object. It is the entry point for performing routing requests. The RoutePlanner
object is initialized using the OnlineRoutePlanner
class.
val routePlanner = OnlineRoutePlanner.create(applicationContext, "YOUR_TOMTOM_API_KEY")
Making routing calls
The routing call is done asynchronously. The call requires the RoutePlanningCallback
to be provided as a parameter to the request. If the call is successful, the callback’s onSuccess(result: RoutePlanningResponse)
method is triggered with the routing result. Additionally the onRoutePlanned(route: Route)
method is invoked for each planned route including the primary route. This method is useful when requesting a route with path alternatives. If a failure occurred, it is provided by the callback’s onFailure(failure: RoutingFailure)
method.
1val amsterdam = GeoPoint(52.377956, 4.897070)2val rotterdam = GeoPoint(51.926517, 4.462456)3val routePlanningOptions = RoutePlanningOptions(itinerary = Itinerary(amsterdam, rotterdam))4routePlanner.planRoute(5 routePlanningOptions,6 object : RoutePlanningCallback {7 override fun onSuccess(result: RoutePlanningResponse) {8 // YOUR CODE GOES HERE9 }1011 override fun onFailure(failure: RoutingFailure) {12 // YOUR CODE GOES HERE13 }1415 override fun onRoutePlanned(route: Route) {16 // YOUR CODE GOES HERE17 }18 },19)

Incremental guidance computation
The mode for guidance computation is controlled by RouteInformationMode
. It contains two cases: Complete
and FirstIncrement
.
The FirstIncrement
is the faster method, but it delivers only the first guidance increment. This guidance increment contains one or more potentially combinable instructions and the corresponding lane guidance.
Next steps
Since you have learned the basics of routing, here are recommendations for the next steps: