RouteController
open class RouteController : NSObject
extension RouteController: Router
A RouteController
tracks the user’s progress along a route, posting notifications as the user reaches significant points along the route. On every location update, the route controller evaluates the user’s location, determining whether the user remains on the route. If not, the route controller calculates a new route.
RouteController
is responsible for the core navigation logic whereas
NavigationViewController
is responsible for displaying a default drop-in navigation UI.
-
A
TileStore
instance used by navigatorDeclaration
Swift
open var navigatorTileStore: TileStore { get }
-
Declaration
Swift
public var indexedRoute: IndexedRoute { get }
-
Declaration
Swift
public var route: Route { get }
-
Details about the user’s progress along the current route, leg, and step.
Declaration
Swift
public var routeProgress: RouteProgress { get set }
-
The most recently received user location.
Note
This is a raw location received fromlocationManager
. To obtain an idealized location, use thelocation
property.Declaration
Swift
public var rawLocation: CLLocation? { get set }
-
Declaration
Swift
public var reroutesProactively: Bool
-
Declaration
Swift
public var refreshesRoute: Bool
-
The route controller’s delegate.
Declaration
Swift
public weak var delegate: RouterDelegate?
-
The route controller’s associated location manager.
Declaration
Swift
public unowned var dataSource: RouterDataSource
-
The Directions object used to create the route.
Declaration
Swift
public var directions: Directions
-
The idealized user location. Snapped to the route line, if applicable, otherwise raw.
See also
snappedLocation, rawLocationDeclaration
Swift
public var location: CLLocation? { get }
-
Declaration
Swift
required public init(along route: Route, routeIndex: Int, options: RouteOptions, directions: Directions = Directions.shared, dataSource source: RouterDataSource, tileStoreLocation: TileStoreConfiguration.Location = .default)
-
Declaration
Swift
public func advanceLegIndex()
-
A custom configuration for electronic horizon observations.
Set this property to
nil
to use the default configuration.Declaration
Swift
public var electronicHorizonOptions: ElectronicHorizonOptions? { get set }
-
The road graph that is updated as the route controller tracks the user’s location.
Declaration
Swift
public var roadGraph: RoadGraph { get }
-
The road object store that is updated as the route controller tracks the user’s location.
Declaration
Swift
public var roadObjectStore: RoadObjectStore { get }
-
The road object matcher that allows to match user-defined road objects.
Declaration
Swift
public var roadObjectMatcher: RoadObjectMatcher { get }
-
Path to the directory where history could be stored when
RouteController.writeHistory(completionHandler:)
is called.Declaration
Swift
public static var historyDirectoryURL: URL? { get set }
-
Starts recording history for debugging purposes.
Postcondition
Use thestopRecordingHistory(writingFileWith:)
method to stop recording history and write the recorded history to a file.Declaration
Swift
public static func startRecordingHistory()
-
A closure to be called when history writing ends.
Declaration
Swift
public typealias HistoryFileWritingCompletionHandler = (_ historyFileURL: URL?) -> Void
Parameters
historyFileURL
A URL to the file that contains history data. This argument is
nil
if no history data has been written because history recording has not yet begun. Use thestartRecordingHistory()
method to begin recording before attempting to write a history file. -
Stops recording history, asynchronously writing any recorded history to a file.
Upon completion, the completion handler is called with the URL to a file in the directory specified by
RouteController.historyDirectoryURL
. The file contains details about the route controller’s activity that may be useful to include when reporting an issue to Mapbox.Precondition
Use thestartRecordingHistory()
method to begin recording history. If thestartRecordingHistory()
method has not been called, this method has no effect.Postcondition
To write history incrementally without an interruption in history recording, use the
startRecordingHistory()
method immediately after this method. If you use thestartRecordingHistory()
method inside the completion handler of this method, history recording will be paused while the file is being prepared.Declaration
Swift
public static func stopRecordingHistory(writingFileWith completionHandler: @escaping HistoryFileWritingCompletionHandler)
Parameters
completionHandler
A closure to be executed when the history file is ready.
-
Keys in the user info dictionaries of various notifications posted by instances of
See moreRouteController
.Declaration
Swift
public struct NotificationUserInfoKey : Hashable, Equatable, RawRepresentable
-
Declaration
Swift
public func userIsOnRoute(_ location: CLLocation) -> Bool
-
Declaration
Swift
public func updateRoute(with indexedRoute: IndexedRoute, routeOptions: RouteOptions?)