NavigationMapView
open class NavigationMapView : UIView
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 anCongestionLevel.unknowntraffic congestion level and a matchingMapboxDirections.MapboxStreetsRoadClasswill be replaced with theCongestionLevel.lowcongestion 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
trueand 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 thealternativeTrafficUnknownColor,alternativeTrafficLowColor,alternativeTrafficModerateColor,alternativeTrafficHeavyColor,alternativeTrafficSevereColorproperty for theNavigationMapView.appearance().Declaration
Swift
public var showsCongestionForAlternativeRoutes: Bool -
MapView, which is added on top ofNavigationMapViewand 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? -
A type that represents a
UIViewthat isCourseUpdatable.Declaration
Swift
public typealias UserCourseView = UIView & CourseUpdatable -
A
UserCourseViewused to indicate the user’s location and course on the map.The
UserCourseView‘sUserCourseView.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 } -
A
TileStoreinstance used by map view.Declaration
Swift
open var mapTileStore: TileStore? { get } -
Initializes a newly allocated
NavigationMapViewobject with the specified frame rectangle.Declaration
Swift
public override init(frame: CGRect)Parameters
frameThe frame rectangle for the
NavigationMapView. -
Initializes a newly allocated
NavigationMapViewobject with the specified frame rectangle and type ofNavigationCamera.Declaration
Swift
public init(frame: CGRect, navigationCameraType: NavigationCameraType = .mobile)Parameters
frameThe frame rectangle for the
NavigationMapView.navigationCameraTypeType of
NavigationCamera, which is used for the current instance ofNavigationMapView. -
Returns a
NavigationMapViewobject initialized from data in a given unarchiver.Declaration
Swift
public required init?(coder: NSCoder)Parameters
coderAn 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
NavigationMapViewis retained. IfNavigationMapViewwas not configured to maintain a tile storage - this function does nothing.Declaration
Swift
public func enablePredictiveCaching(options predictiveCacheOptions: PredictiveCacheOptions)Parameters
optionsoptions, 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
NavigationCameraStateis in.followingmode.Declaration
Swift
public func updatePreferredFrameRate(for routeProgress: RouteProgress)Parameters
routeProgressObject, which stores current progress along specific route.
-
Updates
UserCourseViewto provided location.Declaration
Swift
public func updateUserCourseView(_ location: CLLocation, animated: Bool = false)Parameters
locationLocation, where
UserCourseViewshould be shown.animatedProperty, which determines whether
UserCourseViewtransition to new location will be animated.
-
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
routesList of
Routeobjects, which will be shown onMapView.animatedProperty, which determines whether camera movement will be animated while fitting first 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
routeRoute, on which a certainWaypointwill be shown.legIndexIndex, which determines for which
RouteLegWaypointwill be shown. -
Removes all existing
Routeobjects fromMapView, which were added byNavigationMapView.Declaration
Swift
public func removeRoutes() -
Removes all existing
Waypointobjects fromMapView, which were added byNavigationMapView.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
routeRouteobject, for which maneuver arrows will be shown.legIndexZero-based index of the
RouteLegwhich contains the maneuver.stepIndexZero-based index of the
RouteStepwhich contains the maneuver. -
Removes the
RouteSteparrow from theMapView.Declaration
Swift
public func removeArrow() -
Shows voice instructions for specific
Routeobject.Declaration
Swift
public func showVoiceInstructionsOnMap(route: Route)Parameters
routeRouteobject, along which voice instructions will be shown.
-
Receives coordinates for searching the map for buildings. If buildings are found, they will be highlighted in 2D or 3D depending on the
in3Dvalue.Declaration
Swift
public func highlightBuildings(at coordinates: [CLLocationCoordinate2D], in3D extrudesBuildings: Bool = true, completion: ((_ foundAllBuildings: Bool) -> Void)? = nil)Parameters
coordinatesCoordinates which represent building locations.
extrudesBuildingsSwitch which allows to highlight buildings in either 2D or 3D. Defaults to true.
completionAn escaping closure to be executed when the
MapViewfeature querying for allcoordinatesends. A singleBooleanargument in closure indicates whether or not buildings were found for all coordinates. -
Removes the highlight from all buildings highlighted by
highlightBuildings(at:in3D:).Declaration
Swift
public func unhighlightBuildings()
-
Tranform the route data into nested arrays of legs -> steps -> coordinates. The first and last point of adjacent steps overlap and are duplicated.
Declaration
Swift
func parseRoutePoints(route: Route) -> RoutePoints -
Find and cache the index of the upcoming [RouteLineDistancesIndex].
Declaration
Swift
public func updateUpcomingRoutePointIndex(routeProgress: RouteProgress) -
Calculates the distance between 2 points using EPSG:3857 projection.
Declaration
Swift
func calculateDistance(coordinate1: CLLocationCoordinate2D, coordinate2: CLLocationCoordinate2D) -> Double -
Updates the route line appearance from the origin point to the indicated point
Declaration
Swift
func updateTraveledRouteLine(_ coordinate: CLLocationCoordinate2D?)Parameters
coordinatecurrent position of the puck
-
Updates the route style layer and its casing style layer to gradually disappear as the user location puck travels along the displayed route.
Declaration
Swift
public func updateRoute(_ routeProgress: RouteProgress)Parameters
routeProgressCurrent route progress.
-
Given a congestion level, return its associated color.
Declaration
Swift
func congestionColor(for congestionLevel: String?, isMain: Bool) -> UIColor -
A components, designed to help manage
NavigationMapViewornaments logic.Declaration
Swift
class OrnamentsController : NavigationComponent, NavigationComponentDelegate -
A component meant to assist displaying route line and related items like arrows, waypoints, annotations and other.
Declaration
Swift
class RouteOverlayController : NavigationComponent, NavigationComponentDelegate
Install in Dash
NavigationMapView Class Reference