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
.
-
Declaration
Swift
typealias IndexedRouteResponseCompletionHandler = (_ result: Result<IndexedRouteResponse, DirectionsError>) -> Void
-
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 selectedrouteIndex
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 ofroutes
remain unchanged comparing to originalindexedRouteResponse
. 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.
-
refreshRoute(indexedRouteResponse:fromLegAtIndex:currentRouteShapeIndex:currentLegShapeIndex:completionHandler:)
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 selectedrouteIndex
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 ofroutes
remain unchanged comparing to originalindexedRouteResponse
. 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.