NavigationMapView

open class NavigationMapView : UIView
extension NavigationMapView: CLLocationManagerDelegate
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.

  • Maximum distance (in screen points) the user can tap for a selection to be valid when selecting an alternate route.

    Declaration

    Swift

    public var tapGestureDistanceThreshold: CGFloat
  • Gesture recognizer, that is used to detect taps on waypoints and routes that are currently present on the map. Enabled by default.

    Declaration

    Swift

    public private(set) var mapViewTapGestureRecognizer: UITapGestureRecognizer! { get }
  • 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(),
                         legIndex: Int? = nil,
                         animated: Bool = false,
                         duration: TimeInterval = 1.0,
                         completion: AnimationCompletionHandler? = 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.

    routesPresentationStyle

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

    legIndex

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

    animated

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

    duration

    Duration of the animation (in seconds). In case if animated parameter is set to false this value is ignored.

    completion

    A completion handler that will be called once routes presentation completes.

  • Visualizes the given routes and it’s alternatives, removing any existing 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(_ routeResponse: IndexedRouteResponse,
                         routesPresentationStyle: RoutesPresentationStyle = .all(),
                         legIndex: Int? = nil,
                         animated: Bool = false,
                         duration: TimeInterval = 1.0,
                         completion: AnimationCompletionHandler? = nil)

    Parameters

    routeResponse

    IndexedRouteResponse containing routes to visualize. The selected route by routeIndex is considered primary, while the remaining routes are displayed as if they are currently deselected or inactive.

    routesPresentationStyle

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

    legIndex

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

    animated

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

    duration

    Duration of the animation (in seconds). In case if animated parameter is set to false this value is ignored.

    completion

    A completion handler that will be called once routes presentation completes.

  • 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],
                     layerPosition: MapboxMaps.LayerPosition? = nil,
                     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.

    layerPosition

    Position of the first route layer. Remaining routes and their casings are always displayed below the first and all other subsequent route layers. Defaults to nil. If layer position is set to nil, the route layer appears below the bottommost symbol layer.

    legIndex

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

  • Visualizes the given routes and it’s alternatives, removing any existing 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 removeRoutes() and removeContinuousAlternativesRoutes() methods.

    Declaration

    Swift

    public func show(_ routeResponse: IndexedRouteResponse,
                     layerPosition: MapboxMaps.LayerPosition? = nil,
                     legIndex: Int? = nil)

    Parameters

    routeResponse

    IndexedRouteResponse containing routes to visualize. The selected route by routeIndex is considered primary, while the remaining routes are displayed as if they are currently deselected or inactive.

    layerPosition

    Position of the first route layer. Remaining routes and their casings are always displayed below the first and all other subsequent route layers. Defaults to nil. If layer position is set to nil, the route layer appears below the bottommost symbol layer.

    legIndex

    The zero-based index of the currently active leg along the primary 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()
  • Removes all alternative routes that are currently shown on a map.

    Declaration

    Swift

    public func removeAlternativeRoutes()
  • 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?
  • 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.

  • Shows a callout containing the relative duration to the primary route of each continuous alternative 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 showContinuousAlternativeRoutesDurations()
  • 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,
                                   extrudeAll: Bool = false,
                                   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.

    extrudeAll

    Switch which allows to extrude either all or only buildings at a specific coordinates. Defaults to false.

    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()
  • Visualizes the given alternative routes, removing any existing from the map.

    Each route is visualized as a line. Each route is displayed as a separate line as an inactive route, drawn from it’s deviation point and below the main route line.

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

    Declaration

    Swift

    public func show(continuousAlternatives: [AlternativeRoute])

    Parameters

    continuousAlternatives

    The routes to visualize.

  • Remove any lines visualizing continuous alternatives routes from the map.

    This method undoes the effects of the show(continuousAlternatives:) method.

    Declaration

    Swift

    public func removeContinuousAlternativesRoutes()
  • Returns a list of the AlternativeRoutes, that are close to a certain point and are within threshold distance defined in NavigationMapView.tapGestureDistanceThreshold.

    Declaration

    Swift

    public func continuousAlternativeRoutes(closeTo point: CGPoint) -> [AlternativeRoute]?

    Parameters

    point

    Point on the screen.

    Return Value

    List of the alternative routes, which were found. If there are no continuous alternatives routes on the map view nil will be returned.