NavigationViewController

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

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 RouteResponse 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.

Route initialization should be configured before view controller’s view is loaded. Usually, that is automatically done during any of the inits, but you may also change this settings via prepareViewLoading(routeResponse:, routeIndex:, routeOptions:, navigationOptions:) methods. For example that could be handy while configuring a ViewController for a UIStoryboardSegue.

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.

Important

Creating an instance of this type with parameters that uses RouteController with will start an Active Guidance session. The trip session is stopped when the instance is deallocated. For more info read the Pricing Guide.
  • Initializes a NavigationViewController 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 routeResponse: RouteResponse, routeIndex: Int, routeOptions: RouteOptions, navigationOptions: NavigationOptions? = nil)

    Parameters

    routeResponse

    RouteResponse object, containing selection of routes to follow.

    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.

  • Initializes a NavigationViewController with the given route and navigation service.

    Declaration

    Swift

    public convenience init(navigationService service: NavigationService)

    Parameters

    navigationService

    The navigation service that manages navigation along the route. Route data and options will be extracted from this instance.

  • Updates key settings before loading the view.

    This method basically re-runs the setup which takes place in init. It could be useful if some of the attributes have changed before NavigationViewController did load it’s view, or if you did not have access to initializing logic. For example, as a part of UIStoryboardSegue configuration.

    Declaration

    Swift

    public func prepareViewLoading(routeResponse: RouteResponse, routeIndex: Int, routeOptions: RouteOptions, navigationOptions: NavigationOptions? = nil) -> Bool

    Parameters

    routeResponse

    RouteResponse object, containing selection of routes to follow.

    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.