OnlineRoutePlanner

public final class OnlineRoutePlanner : RoutePlanner

The Online Route Planner is a REST wrapper for a suite of web services that allow developers to use our scalable routing engine.

Lifecycle

  • Declaration

    Swift

    public convenience init(apiKey: String)

    Parameters

    apiKey

    A valid TomTom Service API Key.

  • Initializer with the option to specify a Base URL.

    Declaration

    Swift

    public convenience init(baseURL: String, apiKey: String)

    Parameters

    baseURL

    A base URL to use for requests. Without the endpoint, as String. An example: “https://api.tomtom.com/routing/1”. The base URL should support the endpoints “calculateRoute” and “calculateLongDistanceEVRoute”.

    apiKey

    A valid TomTom Service API Key.

Public

  • This function calculates a route between an origin and a destination, passing through waypoints (if specified). Additional routing parameters like traffic, things to avoid, departure/arrival time, etc. can be taken into account using RoutePlanningOptions.

    Declaration

    Swift

    public func planRoute(
        options: RoutePlanningOptions,
        onRouteReady: ((Route) -> ())?,
        completion: @escaping (Result<RoutePlanningResponse, Error>) -> ()
    )

    Parameters

    options

    The RoutePlanningOptions with parameters for the request

    onRouteReady

    The onRouteReady closure is not used. Online incremental path alternatives are not implemented.

    completion

    The completion closure is called on the main queue after the response to the request has been processed. If no errors occurred, RoutingResponse contains an array of routes between an origin and a destination. The error type is RoutingError

  • Cancels all current requests.

    Declaration

    Swift

    public func cancelPendingRequests()
  • This function calculates route contents (instructions, lane guidance) within its certain part using the provided [RouteIncrementOptions] object.

    Note

    Route ETA should be updated outside [increment] call

    Note

    It’s currently expected that only following Route contents will be updated: Route.legs(i).instructions Route.laneSections

    Important

    This is a Public Preview API. It may be changed or removed at any time.

    Declaration

    Swift

    public func advanceGuidanceProgress(with options: RouteIncrementOptions) -> Result<Route, Error>

    Parameters

    options

    The RoutePlanningOptions.

    Return Value

    If the call succeeds, return a Route. If it fails, return an Error.