THIS SDK ISDEPRECATED. We rolled out a new and better SDK for you.
Allow your users to plan a route that avoids toll roads, motorways, ferries, unpaved roads, carpool
lanes, roads that they have already taken, vignettes, or even whole areas.
Sample use case: You plan a trip between the TomTom offices in Amsterdam and Oslo. 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 use motorways so you can choose the best route.
Available routes to avoid:
Copy 1 routeAvoid = Avoid . TOLL_ROADS
2 routeAvoid = Avoid . MOTORWAYS
3 routeAvoid = Avoid . FERRIES
4 routeAvoid = Avoid . UNPAVED_ROADS
5 routeAvoid = Avoid . CAR_POOLS
6 routeAvoid = Avoid . ALREADY_USED_ROADS
To request a route for a specified route avoid:
Copy 1 RouteDescriptor routeDescriptor = new RouteDescriptor . Builder ( )
3 . considerTraffic ( false )
6 RouteCalculationDescriptor routeCalculationDescriptor = new RouteCalculationDescriptor . Builder ( )
7 . routeDescription ( routeDescriptor )
9 . reportType ( ReportType . NONE )
10 . instructionType ( InstructionsType . NONE )
13 RouteSpecification routeSpecification = new RouteSpecification . Builder (
14 routeConfig . getOrigin ( ) ,
15 routeConfig . getDestination ( )
17 . routeCalculationDescriptor ( routeCalculationDescriptor )
Copy 1 val routeDescriptor = RouteDescriptor . Builder ( )
2 . avoidType ( listOf ( avoidType ) )
3 . considerTraffic ( false )
6 val routeCalculationDescriptor = RouteCalculationDescriptor . Builder ( )
7 . routeDescription ( routeDescriptor )
8 . maxAlternatives ( MAX_ALTERNATIVES )
9 . reportType ( ReportType . NONE )
10 . instructionType ( InstructionsType . NONE )
13 val routeSpecification = RouteSpecification . Builder ( origin , destination )
14 . routeCalculationDescriptor ( routeCalculationDescriptor )
Route avoid ferries
Route avoid motorways
Route avoid toll roads
Sample use case: You plan a trip from A to B and you know that on your way there are vignettes.
Additionally, there is an area which has very high traffic. You want to avoid both vignettes and the
specified area.
To avoid vignettes:
Copy 1 List < String > avoidVignettesList = new ArrayList < > ( ) ;
2 avoidVignettesList . add ( "HUN" ) ;
3 avoidVignettesList . add ( "CZE" ) ;
4 avoidVignettesList . add ( "SVK" ) ;
6 RouteSpecification routeSpecification = RouteSpecificationFactory . createRouteForAvoidsVignettesAndAreas ( avoidVignettesList , routeConfig ) ;
Copy 1 val listOfVignettes = listOf ( "HUN" , "CZE" , "SVK" )
2 val routeCalculationDescriptor = RouteCalculationDescriptor . Builder ( )
3 . routeDescription ( createRouteDescriptor ( ) )
4 . maxAlternatives ( MAX_ALTERNATIVES )
5 . reportType ( ReportType . NONE )
6 . instructionType ( InstructionsType . NONE )
7 . avoidVignettes ( avoidVignettesList )
10 val routeSpecification = RouteSpecification . Builder ( routeConfig . origin , routeConfig . destination )
11 . routeCalculationDescriptor ( routeCalculationDescriptor )
To avoid an area:
Copy 1 BoundingBox boundingBox = new BoundingBox ( ARAD_TOP_LEFT_NEIGHBORHOOD , ARAD_BOTTOM_RIGHT_NEIGHBORHOOD ) ;
3 List < BoundingBox > avoidAreas = new ArrayList < > ( ) ;
4 avoidAreas . add ( boundingBox ) ;
6 RouteSpecification routeSpecification = RouteSpecificationFactory . createRouteForAvoidsArea ( avoidAreas , routeConfig ) ;
Copy 1 val boundingBox = BoundingBox ( Locations . ARAD_TOP_LEFT_NEIGHBORHOOD , Locations . ARAD_BOTTOM_RIGHT_NEIGHBORHOOD )
2 val routeCalculationDescriptor = RouteCalculationDescriptor . Builder ( )
3 . routeDescription ( createRouteDescriptor ( ) )
4 . maxAlternatives ( MAX_ALTERNATIVES )
5 . reportType ( ReportType . NONE )
6 . instructionType ( InstructionsType . NONE )
7 . avoidAreas ( listOf ( avoidArea ) )
10 val routeSpecification = RouteSpecification . Builder ( routeConfig . origin , routeConfig . destination )
11 . routeCalculationDescriptor ( routeCalculationDescriptor )
Route without avoiding anything
Route avoiding a specified area
Route avoiding vignettes