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

Routing with alternative routes

Routing with alternative routes

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.

To request a route with alternatives:

_

RouteQuery queryBuilder = RouteQueryBuilder.create(routeConfig.getOrigin(), routeConfig.getDestination())
        .withMaxAlternatives(maxAlternatives)
        .withReport(Report.EFFECTIVE_SETTINGS)
        .withInstructionsType(InstructionsType.TEXT)
        .withConsiderTraffic(false).build();
val routeQuery = RouteQueryBuilder.create(origin, destination)
        .withMaxAlternatives(maxAlternatives)
        .withConsiderTraffic(false)
        .build()


image

One alternative route

image

Three alternative routes

image

Five alternative routes

You are here