RouteController
open class RouteController: NSObject
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.
-
The route controller’s delegate.
Declaration
Swift
@objc public weak var delegate: RouteControllerDelegate?
-
The Directions object used to create the route.
Declaration
Swift
@objc public var directions: Directions
-
The route controller’s associated location manager.
Declaration
Swift
@objc public var locationManager: NavigationLocationManager!
-
If true, location updates will be simulated when driving through tunnels or other areas where there is none or bad GPS reception.
Declaration
Swift
@objc public var isDeadReckoningEnabled = false
-
If true, the
RouteController
attempts to calculate a more optimal route for the user on an interval defined byRouteControllerOpportunisticReroutingInterval
.Declaration
Swift
@objc public var reroutesOpportunistically = false
-
Details about the user’s progress along the current route, leg, and step.
Declaration
Swift
public var routeProgress: RouteProgress
-
Intializes a new
RouteController
.Declaration
Swift
public init(along route: Route, directions: Directions = Directions.shared, locationManager: NavigationLocationManager = NavigationLocationManager())
Parameters
route
The route to follow.
directions
The Directions object that created
route
.locationManager
The associated location manager.
-
Starts monitoring the user’s location along the route.
Will continue monitoring until
suspendLocationUpdates()
is called.Declaration
Swift
@objc public func resume()
-
Stops monitoring the user’s location along the route.
Declaration
Swift
@objc public func suspendLocationUpdates()
-
The most recently received user location, snapped to the route line.
This property contains a
CLLocation
object located along the route line near the most recently received user location. This property is set tonil
if the route controller is unable to snap the user’s location to the route line for some reason.Declaration
Swift
@objc public var location: CLLocation?
-
Send feedback about the current road segment/maneuver to the Mapbox data team.
You can pair this with a custom feedback UI in your app to flag problems during navigation such as road closures, incorrect instructions, etc.
@param type A
FeedbackType
used to specify the type of feedback @param description A custom string used to describe the problem in detail. @return Returns a UUID string used to identify the feedback eventIf you provide a custom feedback UI that lets users elaborate on an issue, you should call this before you show the custom UI so the location and timestamp are more accurate.
You can then call
updateFeedback(feedbackId:)
with the returned feedback ID string to attach any additional metadata to the feedback.Declaration
Swift
@objc public func recordFeedback(type: FeedbackType = .general, description: String? = nil) -> String
-
Update the feedback event with a specific feedback ID. If you implement a custom feedback UI that lets a user elaborate on an issue, you can use this to update the metadata.
Note that feedback is sent 20 seconds after being recorded, so you should promptly update the feedback metadata after the user discards any feedback UI.
Declaration
Swift
@objc public func updateFeedback(feedbackId: String, type: FeedbackType, source: FeedbackSource, description: String?)
-
Discard a recorded feedback event, for example if you have a custom feedback UI and the user cancelled feedback.
Declaration
Swift
@objc public func cancelFeedback(feedbackId: String)
-
Set the rating and any comment the user may have about their route. Only used when exiting navigaiton.
Declaration
Swift
@objc public func setEndOfRoute(rating: Int, comment: String?)
-
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
@objc public func userIsOnRoute(_ location: CLLocation) -> Bool