NavigationMapView

open class NavigationMapView : UIView
extension NavigationMapView: UIGestureRecognizerDelegate

NavigationMapView is a subclass of UIView, which draws MapView on its surface and provides convenience functions for adding Route lines to a map.

  • A collection of street road classes for which a congestion level substitution should occur.

    For any street road class included in the roadClassesWithOverriddenCongestionLevels, all route segments with an CongestionLevel.unknown traffic congestion level and a matching MapboxDirections.MapboxStreetsRoadClass. will be replaced with the CongestionLevel.low congestion level.

    Declaration

    Swift

    public var roadClassesWithOverriddenCongestionLevels: Set<MapboxStreetsRoadClass>?
  • Controls whether to show congestion levels on alternative route lines. Defaults to false.

    If true and there’re multiple routes to choose, the alternative route lines would display the congestion levels at different colors, similar to the main route. To customize the congestion colors that represent different congestion levels, override the alternativeTrafficUnknownColor, alternativeTrafficLowColor, alternativeTrafficModerateColor, alternativeTrafficHeavyColor, alternativeTrafficSevereColor property for the NavigationMapView.appearance().

    Declaration

    Swift

    public var showsCongestionForAlternativeRoutes: Bool
  • Controls whether to show fading gradient color on route lines between two different congestion level segments. Defaults to false.

    If true, the congestion level change between two segments in the route line will be shown as fading gradient color instead of abrupt and steep change.

    Declaration

    Swift

    public var crossfadesCongestionSegments: Bool { get set }
  • Maximum distance the user can tap for a selection to be valid when selecting an alternate route.

    Declaration

    Swift

    public var tapGestureDistanceThreshold: CGFloat
  • Visualizes the given routes and their waypoints and zooms the map to fit, removing any existing routes and waypoints from the map.

    Each route is visualized as a line. Each line is color-coded by traffic congestion, if congestion levels are present and NavigationMapView.crossfadesCongestionSegments is set to true.

    Waypoints along the route are visualized as markers. Implement NavigationMapViewDelegate methods to customize the appearance of the lines and markers representing the routes and waypoints.

    To only visualize the routes and not the waypoints, or to have more control over the camera, use the show(_:legIndex:) method.

    Declaration

    Swift

    public func showcase(_ routes: [Route],
                         routesPresentationStyle: RoutesPresentationStyle = .all(),
                         animated: Bool = false)

    Parameters

    routes

    The routes to visualize in order of priority. The first route is displayed as if it is currently selected or active, while the remaining routes are displayed as if they are currently deselected or inactive. The order of routes in this array may differ from the order in the original RouteResponse, for example in response to a user selecting a preferred route.

    routesPresentationStyle

    Route lines presentation style. By default the map will be updated to fit all routes.

    animated

    true to asynchronously animate the camera, or false to instantaneously zoom and pan the map.

  • Visualizes the given routes, removing any existing routes from the map.

    Each route is visualized as a line. Each line is color-coded by traffic congestion, if congestion levels are present. Implement NavigationMapViewDelegate methods to customize the appearance of the lines representing the routes. To also visualize waypoints and zoom the map to fit, use the showcase(_:animated:) method.

    To undo the effects of this method, use the removeRoutes() method.

    Declaration

    Swift

    public func show(_ routes: [Route], legIndex: Int? = nil)

    Parameters

    routes

    The routes to visualize in order of priority. The first route is displayed as if it is currently selected or active, while the remaining routes are displayed as if they are currently deselected or inactive. The order of routes in this array may differ from the order in the original RouteResponse, for example in response to a user selecting a preferred route.

    legIndex

    The zero-based index of the currently active leg along the active route. The active leg is highlighted more prominently than inactive legs.

  • Remove any lines visualizing routes from the map.

    This method undoes the effects of the show(_:legIndex:) method.

    Declaration

    Swift

    public func removeRoutes()
  • Shows the step arrow given the current RouteProgress.

    Declaration

    Swift

    public func addArrow(route: Route, legIndex: Int, stepIndex: Int)

    Parameters

    route

    Route object, for which maneuver arrows will be shown.

    legIndex

    Zero-based index of the RouteLeg which contains the maneuver.

    stepIndex

    Zero-based index of the RouteStep which contains the maneuver.

  • Removes the RouteStep arrow from the MapView.

    Declaration

    Swift

    public func removeArrow()
  • PointAnnotationManager, which is used to manage addition and removal of final destination annotation. PointAnnotationManager will become valid only after fully loading MapView style.

    Declaration

    Swift

    public var pointAnnotationManager: PointAnnotationManager?
  • MapView, which is added on top of NavigationMapView and allows to render navigation related components.

    Declaration

    Swift

    public private(set) var mapView: MapView! { get }
  • The object that acts as the navigation delegate of the map view.

    Declaration

    Swift

    public weak var delegate: NavigationMapViewDelegate?
  • Attempts to localize labels into the system’s preferred language.

    This method automatically modifies the SymbolLayer.textField property of any symbol style layer whose source is the Mapbox Streets source. The user can set the system’s preferred language in Settings, General Settings, Language & Region.

    This method avoids localizing road labels into the system’s preferred language, in an effort to match road signage and the turn banner, which always display road names and exit destinations in the local language. If this NavigationMapView stands alone outside a NavigationViewController, you should call the MapboxMap.onEvery(_:handler:) on mapView, passing in MapEvents.EventKind.styleLoaded, and call this method inside the closure. The map view embedded in NavigationViewController is localized automatically, so you do not need to call this method on the value of NavigationViewController.navigationMapView.

    Declaration

    Swift

    public func localizeLabels()
  • Shows voice instructions for specific Route object.

    Declaration

    Swift

    public func showVoiceInstructionsOnMap(route: Route)

    Parameters

    route

    Route object, along which voice instructions will be shown.

  • Initializes a newly allocated NavigationMapView object with the specified frame rectangle.

    Declaration

    Swift

    public override init(frame: CGRect)

    Parameters

    frame

    The frame rectangle for the NavigationMapView.

  • Initializes a newly allocated NavigationMapView object with the specified frame rectangle and type of NavigationCamera.

    Declaration

    Swift

    public init(frame: CGRect,
                navigationCameraType: NavigationCameraType = .mobile,
                tileStoreLocation: TileStoreConfiguration.Location? = .default)

    Parameters

    frame

    The frame rectangle for the NavigationMapView.

    navigationCameraType

    Type of NavigationCamera, which is used for the current instance of NavigationMapView.

    tileStoreLocation

    Configuration of TileStore location, where Map tiles are stored. Use nil to disable onboard tile storage.

  • Returns a NavigationMapView object initialized from data in a given unarchiver.

    Declaration

    Swift

    public required init?(coder: NSCoder)

    Parameters

    coder

    An unarchiver object.

  • A TileStore instance used by map view.

    Declaration

    Swift

    open var mapTileStore: TileStore? { get }
  • Setups the Predictive Caching mechanism using provided Options.

    This will handle all the required manipulations to enable the feature and maintain it during the navigations. Once enabled, it will be present as long as NavigationMapView is retained.

    Declaration

    Swift

    public func enablePredictiveCaching(options predictiveCacheOptions: PredictiveCacheOptions)

    Parameters

    options

    options, controlling caching parameters like area radius and concurrent downloading threads.

  • Receives coordinates for searching the map for buildings. If buildings are found, they will be highlighted in 2D or 3D depending on the in3D value.

    Declaration

    Swift

    public func highlightBuildings(at coordinates: [CLLocationCoordinate2D],
                                   in3D extrudesBuildings: Bool = true,
                                   completion: ((_ foundAllBuildings: Bool) -> Void)? = nil)

    Parameters

    coordinates

    Coordinates which represent building locations.

    extrudesBuildings

    Switch which allows to highlight buildings in either 2D or 3D. Defaults to true.

    completion

    An escaping closure to be executed when the MapView feature querying for all coordinates ends. A single Boolean argument in closure indicates whether or not buildings were found for all coordinates.

  • Removes the highlight from all buildings highlighted by highlightBuildings(at:in3D:completion:).

    Declaration

    Swift

    public func unhighlightBuildings()