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

Documentation

Documentation

This component integrates Routing API described on
https://developer.tomtom.com/routing-api/routing-api-documentation
The service calculates a route between an origin and a destination,
passing through waypoints if they are specified.

Routing API is one of our most advanced APIs, enabling the user to
calculate a perfect path from point A to point B.

  • RoutingBuilder is instantiated with the API Key for the TomTom Online
    Routing service

  • You can set an origin and a destination, if you want to route from the
    current location, then simply pass it to the from() method of the
    RoutingBuilder

  • You can set a list of via points to lead the way though them

  • You can provide locations as points, or as approximate points
    (circles)

To initialise routing:

_

routePlannerAPI = OnlineRoutingApi.create(context);
private val routingApi = OnlineRoutingApi.create(context)!!

To execute routing:

_

Disposable subscribe = routePlannerAPI.planRoute(routeQuery).subscribeOn(getWorkingScheduler())
        .observeOn(getResultScheduler())
        .subscribe(routeResult -> displayRoutes(routeResult, routeStyle, startIcon, endIcon),
                throwable -> proceedWithError(throwable.getMessage()));
Disposable subscribe = routePlannerAPI.planRoute(routeQuery).subscribeOn(getWorkingScheduler())
        .observeOn(getResultScheduler())
        .subscribe(
                routeResult -> displayRoutes(routeResult),
                throwable -> proceedWithError(throwable.getMessage()));
disposable.set(routingApi.planRoute(routeQuery)
        .subscribeOn(workingScheduler)
        .observeOn(resultScheduler)
        .subscribe(
                { response -> result.value = Resource.success(response.routes) },
                { error -> result.value = Resource.error(null, Error(error.message)) }
        )
)

To display route on the map:

_

RouteBuilder routeBuilder = new RouteBuilder(route.getCoordinates())
        .endIcon(endIcon)
        .startIcon(startIcon)
        .style(routeStyle);
final Route mapRoute = tomtomMap.addRoute(routeBuilder);
val routeBuilder = RouteBuilder(route.coordinates)
        .style(RouteStyle.DEFAULT_ROUTE_STYLE)
        .startIcon(createIcon(R.drawable.ic_map_route_origin))
        .endIcon(createIcon(R.drawable.ic_map_route_destination))
        .tag(routeIdx.toString())
tomtomMap.addRoute(routeBuilder)

You are here