Router
public protocol Router : AnyObject, CLLocationManagerDelegate
A class conforming to the Router protocol tracks the user’s progress as they travel along a predetermined route. It calls methods on its delegate, which conforms to the RouterDelegate protocol, whenever significant events or decision points occur along the route. Despite its name, this protocol does not define the interface of a routing engine.
There are two concrete implementations of the Router protocol. RouteController, the default implementation, is capable of client-side routing and depends on the Mapbox Navigation Native framework. LegacyRouteController is an alternative implementation that does not have this dependency but must be used in conjunction with the Mapbox Directions API over a network connection.
-
The route controller’s associated location manager.
Declaration
Swift
var dataSource: RouterDataSource { get } -
The route controller’s delegate.
Declaration
Swift
var delegate: RouterDelegate? { get set } -
Intializes a new
RouteController.Declaration
Swift
init(along route: Route, options: RouteOptions, directions: Directions, dataSource source: RouterDataSource)Parameters
routeThe route to follow.
directionsThe Directions object that created
route.sourceThe data source for the RouteController.
-
Details about the user’s progress along the current route, leg, and step.
Declaration
Swift
var routeProgress: RouteProgress { get } -
Given a users current location, returns a Boolean whether they are currently on the route.
If the user is not on the route, they should be rerouted.
Declaration
Swift
func userIsOnRoute(_ location: CLLocation) -> Bool -
The idealized user location. Snapped to the route line, if applicable, otherwise raw or nil.
Declaration
Swift
var location: CLLocation? { get } -
The most recently received user location.
Note
This is a raw location received fromlocationManager. To obtain an idealized location, use thelocationproperty.Declaration
Swift
var rawLocation: CLLocation? { get } -
If true, the
RouteControllerattempts to calculate a more optimal route for the user on an interval defined byRouteControllerProactiveReroutingInterval.Declaration
Swift
var reroutesProactively: Bool { get set } -
Advances the leg index.
This is a convienence method provided to advance the leg index of any given router without having to worry about the internal data structure of the router.
Declaration
Swift
func advanceLegIndex(location: CLLocation)
Install in Dash
Router Protocol Reference