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.

  • The minimum preferred frames per second at which to render map animations.

    This property takes effect when the application has limited resources for animation, such as when the device is running on battery power. By default, this property is set to PreferredFPS.normal.

    Declaration

    Swift

    public var minimumFramesPerSecond: PreferredFPS
  • Maximum distance the user can tap for a selection to be valid when selecting an alternate route.

    Declaration

    Swift

    public var tapGestureDistanceThreshold: CGFloat
  • 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>?
  • NavigationCamera, which allows to control camera states.

    Declaration

    Swift

    public private(set) var navigationCamera: NavigationCamera! { get }
  • 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
  • List of Mapbox Maps font names to be used for any symbol layers added by the Navigation SDK. These are used for features such as Route Duration Annotations that are optionally added during route preview. See https://docs.mapbox.com/ios/maps/api/6.3.0/customizing-fonts.html for more information about server-side fonts.

    Declaration

    Swift

    @objc
    dynamic public var routeDurationAnnotationFontNames: [String]
  • 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?
  • 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?
  • A UserCourseView used to indicate the user’s location and course on the map.

    The UserCourseView‘s UserCourseView.update(location:pitch:direction:animated:) method is frequently called to ensure that its visual appearance matches the map’s camera.

    Declaration

    Swift

    public var userCourseView: UserCourseView { get set }
  • Specifies how the map displays the user’s current location, including the appearance and underlying implementation.

    By default, this property is set to UserLocationStyle.courseView, the bearing source is location course.

    Declaration

    Swift

    public var userLocationStyle: UserLocationStyle { get set }
  • A TileStore instance used by map view.

    Declaration

    Swift

    open var mapTileStore: TileStore? { get }
  • 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.

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

  • Updates the map view’s preferred frames per second to the appropriate value for the current route progress.

    This method accounts for the proximity to a maneuver and the current power source. It has no effect if NavigationCamera is in NavigationCameraState.following state.

    Declaration

    Swift

    public func updatePreferredFrameRate(for routeProgress: RouteProgress)

    Parameters

    routeProgress

    Object, which stores current progress along specific route.

  • Showcases route array. Adds routes and waypoints to map, and sets camera to point encompassing the route.

    Declaration

    Swift

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

    Parameters

    routes

    List of Route objects, which will be shown on MapView.

    animated

    Property, which determines whether camera movement will be animated while fitting first route.

  • Adds main and alternative route lines and their casings on MapView. Prior to showing, previous route lines and their casings will be removed.

    Declaration

    Swift

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

    Parameters

    routes

    List of Route objects, which will be shown on MapView.

    legIndex

    Index, which will be used to highlight specific RouteLeg on main route.

  • Adds the route waypoints to the map given the current leg index. Previous waypoints for completed legs will be omitted.

    Declaration

    Swift

    public func showWaypoints(on route: Route, legIndex: Int = 0)

    Parameters

    route

    Route, on which a certain Waypoint will be shown.

    legIndex

    Index, which determines for which RouteLeg Waypoint will be shown.

  • Removes all existing Route objects from MapView, which were added by NavigationMapView.

    Declaration

    Swift

    public func removeRoutes()
  • Removes all existing Waypoint objects from MapView, which were added by NavigationMapView.

    Declaration

    Swift

    public func removeWaypoints()
  • 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()
  • Shows a callout containing the duration of each route. Useful as a way to give the user more information when picking between multiple route alternatives. If the route contains any tolled segments then the callout will specify that as well.

    Declaration

    Swift

    public func showRouteDurations(along routes: [Route]?)
  • Removes all visible route duration callouts.

    Declaration

    Swift

    public func removeRouteDurations()
  • 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()
  • 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()