RoutingProvider

public protocol RoutingProvider

Protocol which defines a type which can be used for fetching or refreshing routes.

SDK provides conformance to this protocol for Directions and MapboxRoutingProvider.

  • Begins asynchronously calculating routes using the given options and delivers the results to a closure.

    Declaration

    Swift

    @discardableResult
    func calculateRoutes(options: RouteOptions,
                         completionHandler: @escaping IndexedRouteResponseCompletionHandler) -> NavigationProviderRequest?

    Parameters

    options

    A RouteOptions object specifying the requirements for the resulting routes.

    completionHandler

    The closure (block) to call with the resulting routes. This closure is executed on the application’s main thread.

    Return Value

    Related request. If, while waiting for the completion handler to execute, you no longer want the resulting routes, cancel corresponding task using this handle.

  • Begins asynchronously calculating routes using the given options and delivers the results to a closure.

    Declaration

    Swift

    @available(*, deprecated, renamed: "calculateRoutes(options:completionHandler:﹚")
    @discardableResult
    func calculateRoutes(options: RouteOptions,
                         completionHandler: @escaping Directions.RouteCompletionHandler) -> NavigationProviderRequest?

    Parameters

    options

    A RouteOptions object specifying the requirements for the resulting routes.

    completionHandler

    The closure (block) to call with the resulting routes. This closure is executed on the application’s main thread.

    Return Value

    Related request. If, while waiting for the completion handler to execute, you no longer want the resulting routes, cancel corresponding task using this handle.

  • Begins asynchronously calculating matches using the given options and delivers the results to a closure.

    Declaration

    Swift

    @discardableResult
    func calculateRoutes(options: MatchOptions,
                         completionHandler: @escaping Directions.MatchCompletionHandler) -> NavigationProviderRequest?

    Parameters

    options

    A MatchOptions object specifying the requirements for the resulting matches.

    completionHandler

    The closure (block) to call with the resulting matches. This closure is executed on the application’s main thread.

    Return Value

    Related request. If, while waiting for the completion handler to execute, you no longer want the resulting routes, cancel corresponding task using this handle.

  • Begins asynchronously refreshing the route with the given identifier, starting from an arbitrary leg along the route.

    Declaration

    Swift

    @discardableResult
    func refreshRoute(indexedRouteResponse: IndexedRouteResponse,
                      fromLegAtIndex: UInt32,
                      completionHandler: @escaping Directions.RouteCompletionHandler) -> NavigationProviderRequest?

    Parameters

    indexedRouteResponse

    The RouteResponse and selected routeIndex in it to be refreshed.

    fromLegAtIndex

    The index of the leg in the route at which to begin refreshing. The response will omit any leg before this index and refresh any leg from this index to the end of the route. If this argument is 0, the entire route is refreshed.

    completionHandler

    The closure (block) to call with updated RouteResponse data. Order of routes remain unchanged comparing to original indexedRouteResponse. This closure is executed on the application’s main thread.

    Return Value

    Related request. If, while waiting for the completion handler to execute, you no longer want the resulting routes, cancel corresponding task using this handle.

  • Begins asynchronously refreshing the route with the given identifier, starting from an arbitrary leg and shape index along the route.

    Declaration

    Swift

    @discardableResult
    func refreshRoute(indexedRouteResponse: IndexedRouteResponse,
                      fromLegAtIndex: UInt32,
                      currentRouteShapeIndex: Int,
                      currentLegShapeIndex: Int,
                      completionHandler: @escaping Directions.RouteCompletionHandler) -> NavigationProviderRequest?

    Parameters

    indexedRouteResponse

    The RouteResponse and selected routeIndex in it to be refreshed.

    fromLegAtIndex

    The index of the leg in the route at which to begin refreshing. The response will omit any leg before this index and refresh any leg from this index to the end of the route.

    currentRouteShapeIndex

    Index relative to fromLegAtIndex leg shape, representing the point the user is currently located at.

    currentRouteShapeIndex

    Index relative to fromLegAtIndex leg shape, representing the point the user is currently located at.

    completionHandler

    The closure (block) to call with updated RouteResponse data. Order of routes remain unchanged comparing to original indexedRouteResponse. This closure is executed on the application’s main thread.

    Return Value

    Related request. If, while waiting for the completion handler to execute, you no longer want the resulting routes, cancel corresponding task using this handle.