NavigationViewController

open class NavigationViewController : UIViewController, NavigationStatusPresenter
extension NavigationViewController: NavigationServiceDelegate
extension NavigationViewController: StyleManagerDelegate
extension NavigationViewController: TopBannerViewControllerDelegate
extension NavigationViewController: BottomBannerViewControllerDelegate
extension NavigationViewController: CarPlayConnectionObserver

NavigationViewController is a fully-featured user interface for turn-by-turn navigation. Do not confuse it with the NavigationController class in UIKit.

You initialize a navigation view controller based on a predefined Route and NavigationOptions. As the user progresses along the route, the navigation view controller shows their surroundings and the route line on a map. Banners above and below the map display key information pertaining to the route. A list of steps and a feedback mechanism are accessible via the navigation view controller.

To be informed of significant events and decision points as the user progresses along the route, set the NavigationService.delegate property of the NavigationService that you provide when creating the navigation options.

CarPlayNavigationViewController manages the corresponding user interface on a CarPlay screen.

  • A Route object constructed by MapboxDirections along with its index in a RouteResponse.

    In cases where you need to update the route after navigation has started, you can set a new route here and NavigationViewController will update its UI accordingly.

    Declaration

    Swift

    public var indexedRoute: IndexedRoute { get set }
  • A Route object constructed by MapboxDirections.

    Declaration

    Swift

    public var route: Route { get }
  • An instance of Directions need for rerouting. See Mapbox Directions for further information.

    Declaration

    Swift

    public var directions: Directions { get }
  • An optional MGLMapCamera you can use to improve the initial transition from a previous viewport and prevent a trigger from an excessive significant location update.

    Declaration

    Swift

    public var pendingCamera: MGLMapCamera?
  • An instance of MGLAnnotation representing the origin of your route.

    Declaration

    Swift

    public var origin: MGLAnnotation?
  • The receiver’s delegate.

    Declaration

    Swift

    public weak var delegate: NavigationViewControllerDelegate?
  • The voice controller that vocalizes spoken instructions along the route at the appropriate times.

    Declaration

    Swift

    public var voiceController: RouteVoiceController!
  • The navigation service that coordinates the view controller’s nonvisual components, tracking the user’s location as they proceed along the route.

    Declaration

    Swift

    private(set) public var navigationService: NavigationService! { get set }
  • The main map view displayed inside the view controller.

    Note

    Do not change this map view’s NavigationMapView.navigationMapDelegate property; instead, implement the corresponding methods on NavigationViewControllerDelegate.

    Declaration

    Swift

    @objc
    public var mapView: NavigationMapView? { get }
  • Determines whether the user location annotation is moved from the raw user location reported by the device to the nearest location along the route.

    By default, this property is set to true, causing the user location annotation to be snapped to the route.

    Declaration

    Swift

    public var snapsUserLocationAnnotationToRoute: Bool
  • Toggles sending of UILocalNotification upon upcoming steps when application is in the background. Defaults to true.

    Declaration

    Swift

    public var sendsNotifications: Bool
  • Shows a button that allows drivers to report feedback such as accidents, closed roads, poor instructions, etc. Defaults to true.

    Declaration

    Swift

    public var showsReportFeedback: Bool { get set }
  • Shows End of route Feedback UI when the route controller arrives at the final destination. Defaults to true.

    Declaration

    Swift

    public var showsEndOfRouteFeedback: Bool { get set }
  • Shows the current speed limit on the map view.

    The default value of this property is true.

    Declaration

    Swift

    public var showsSpeedLimits: Bool { get set }
  • If true, the map style and UI will automatically be updated given the time of day.

    Declaration

    Swift

    public var automaticallyAdjustsStyleForTimeOfDay: Bool { get set }
  • If true, UIApplication.isIdleTimerDisabled is set to true in viewWillAppear(_:) and false in viewWillDisappear(_:). If your application manages the idle timer itself, set this property to false.

    Declaration

    Swift

    public var shouldManageApplicationIdleTimer: Bool
  • Allows to control highlighting of the destination building on arrival. By default destination buildings will not be highlighted.

    Declaration

    Swift

    public var waypointStyle: WaypointStyle
  • Controls whether the main route style layer and its casing disappears as the user location puck travels over it. Defaults to false.

    If true, the part of the route that has been traversed will be rendered with full transparency, to give the illusion of a disappearing route. To customize the color that appears on the traversed section of a route, override the traversedRouteColor property for the NavigationMapView.appearance().

    Declaration

    Swift

    public var routeLineTracksTraversal: Bool { get set }
  • Controls whether or not the FeedbackViewController shows a second level of detail for feedback items.

    Declaration

    Swift

    public var detailedFeedbackEnabled: Bool { get set }
  • A Boolean value that determines whether the map annotates the locations at which instructions are spoken for debugging purposes.

    Declaration

    Swift

    public var annotatesSpokenInstructions: Bool
  • Initializes a navigation view controller that presents the user interface for following a predefined route based on the given options.

    The route may come directly from the completion handler of the MapboxDirections framework’s Directions.calculate(_:completionHandler:) method, or it may be unarchived or created from a JSON object.

    Declaration

    Swift

    required public init(for route: Route, routeIndex: Int, routeOptions: RouteOptions, navigationOptions: NavigationOptions? = nil)

    Parameters

    route

    The route to navigate along.

    routeIndex

    The index of the route within the original RouteResponse object.

    routeOptions

    The route options used to get the route.

    navigationOptions

    The navigation options to use for the navigation session.