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

    public weak var delegate: RouteControllerDelegate?
  • The Directions object used to create the route.

    Declaration

    Swift

    public var directions: Directions
  • The route controller’s associated location manager.

    Declaration

    Swift

    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

    public var isDeadReckoningEnabled = false
  • If true, every 2 minutes the RouteController will check for a faster route for the user.

    Declaration

    Swift

    public var checkForFasterRouteInBackground = 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

    public func resume()
  • Stops monitoring the user’s location along the route.

    Declaration

    Swift

    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 to nil if the route controller is unable to snap the user’s location to the route line for some reason.

    Declaration

    Swift

    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 event

    If 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

    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

    public func updateFeedback(feedbackId: String, type: FeedbackType, description: String?)
  • Discard a recorded feedback event, for example if you have a custom feedback UI and the user cancelled feedback.

    Declaration

    Swift

    public func cancelFeedback(feedbackId: 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

    public func userIsOnRoute(_ location: CLLocation) -> Bool