PreviewViewController
public class PreviewViewController : UIViewController
extension PreviewViewController: StyleManagerDelegate
PreviewViewController is a user interface for the preview mode experience. It allows to present
banners that contain information that is important for the user before actually starting turn-by-turn
navigation session (e.g. final destination presentation, main and alternative routes preview etc).
By default Mapbox Navigation SDK provides such banners:
DestinationPreviewViewController- banner that is shown at the bottom of the screen and allows to show information about the final destination, preview available routes and start active navigation sessionRoutePreviewViewController- banner that is shown at the bottom of the screen and allows to preview information about the currentRoute(expected travel time, distance and expected time of arrival)BannerDismissalViewController- banner that is shown at the top of the screen and allows to dismiss already presented banner
Internally PreviewViewController relies on two components:
NavigationMapView- wrapsMapViewand provides convenience functions for adding and removing route lines, route duration annotations, shows user location indicator etcNavigationView- wrapsNavigationMapViewand provides the ability to show drop-in related UI components likeSpeedLimitView,WayNameView, top and bottomBannerContainerViews etc
PreviewViewController works as an initial step before switching to the active navigation.
Use NavigationViewController for turn-by-turn navigation experience.
-
NavigationView, that is displayed inside the view controller.Declaration
Swift
public var navigationView: NavigationView { get }
-
PreviewViewControllerDelegatethat allows to observeBannerpresentation and dismissal events.Declaration
Swift
public weak var delegate: PreviewViewControllerDelegate? -
The
NavigationMapView, that is displayed inside the view controller.Declaration
Swift
public var navigationMapView: NavigationMapView { get set }
-
Initializes a
PreviewViewControllerthat presents the user interface for the destination and routes preview.Declaration
Swift
public init(_ previewOptions: PreviewOptions = PreviewOptions())Parameters
previewOptionsCustomization options for the navigation preview user experience.
-
Removes the top-most banner from the banners hierarchy.
Declaration
Swift
@discardableResult public func dismissBanner(at position: BannerPosition, animated: Bool = true, duration: TimeInterval = 0.2, animations: (() -> Void)? = nil, completion: (() -> Void)? = nil) -> Banner?Parameters
positionPosition of the
Banneron the screen.animatedIf true,
PreviewViewControlleranimates the transition between banners.durationDuration of the animation. Defaults to
0.2seconds.animationsA block object containing the changes to commit to the views. This is where you programmatically change any animatable properties of the views in your view hierarchy. This block takes no parameters and has no return value.
completionA block object to be executed when the animation sequence ends. This block has no return value.
Return Value
Bannerthat was dismissed. If there are no more banners in the banners hierarchynilwill be returned instead. -
Removes all of the banners from the banners hierarchy except the first banner.
Declaration
Swift
public func dismissAllExceptFirst(at position: BannerPosition, animated: Bool = true, duration: TimeInterval = 0.2, animations: (() -> Void)? = nil, completion: (() -> Void)? = nil)Parameters
positionPosition of the
Banneron the screen.animatedControls whether
PreviewViewControlleranimates the transition between banners. Defaults totrue.durationDuration of the animation. Defaults to
0.2seconds.animationsA block object containing the changes to commit to the views. This is where you programmatically change any animatable properties of the views in your view hierarchy. This block takes no parameters and has no return value.
completionA block object to be executed when the animation sequence ends. This block has no return value.
-
Adds the specified banner to the banners hierarchy and displays it.
Declaration
Swift
public func present(_ banner: Banner, animated: Bool = true, duration: TimeInterval = 0.2, animations: (() -> Void)? = nil, completion: (() -> Void)? = nil)Parameters
bannerBannerinstance that will be presented.animatedControls whether
PreviewViewControlleranimates the transition between banners. Defaults totrue.durationDuration of the animation. Defaults to
0.2seconds.animationsA block object containing the changes to commit to the views. This is where you programmatically change any animatable properties of the views in your view hierarchy. This block takes no parameters and has no return value.
completionA block object to be executed when the animation sequence ends. This block has no return value.
-
Returns the top-most banner in the banners hierarchy.
Declaration
Swift
public func topBanner(at position: BannerPosition) -> Banner?Parameters
positionPosition of the
Banneron the screen.Return Value
The top-most
Banner. If there are no banners in the banners hierarchynilwill be returned instead.
-
Declaration
Swift
public func location(for styleManager: MapboxNavigation.StyleManager) -> CLLocation? -
Declaration
Swift
public func styleManager(_ styleManager: MapboxNavigation.StyleManager, didApply style: MapboxNavigation.Style)
Install in Dash
PreviewViewController Class Reference