Mapbox Navigation SDK for iOS
The Mapbox Navigation SDK gives you all the tools you need to add turn-by-turn navigation to your application. It takes just a few minutes to drop a full-fledged turn-by-turn navigation view controller into your application. Or use the Core Navigation framework directly to build something truly custom.
The Mapbox Navigation SDK and Core Navigation are compatible with applications written in Swift 5 in Xcode 10.2. The Mapbox Navigation and Mapbox Core Navigation frameworks run on iOS 10.0 and above.
Installation
Using Swift Package Manager
To install the MapboxNavigation framework in an application using Swift Package Manager:
Go to your Mapbox account dashboard and create an access token that has the
DOWNLOADS:READ
scope. PLEASE NOTE: This is not the same as your production Mapbox API token. Make sure to keep it private and do not insert it into any Info.plist file. Create a file named.netrc
in your home directory if it doesn’t already exist, then add the following lines to the end of the file:machine api.mapbox.com login mapbox password PRIVATE_MAPBOX_API_TOKEN
where PRIVATE_MAPBOX_API_TOKEN is your Mapbox API token with the
DOWNLOADS:READ
scope.In Xcode, go to File ‣ Swift Packages ‣ Add Package Dependency.
Enter
https://github.com/mapbox/mapbox-navigation-ios.git
as the package repository and click Next.Set Rules to Version, Up to Next Major, and enter
2.0.0
as the minimum version requirement. Click Next.
To install the MapboxCoreNavigation framework in another package rather than an application, run swift package init
to create a Package.swift, then add the following dependency:
// Latest prerelease
.package(name: "MapboxNavigation", url: "https://github.com/mapbox/mapbox-navigation-ios.git", from: "2.0.0")
Using CocoaPods
To install the MapboxNavigation framework using CocoaPods:
Go to your Mapbox account dashboard and create an access token that has the
DOWNLOADS:READ
scope. PLEASE NOTE: This is not the same as your production Mapbox API token. Make sure to keep it private and do not insert it into any Info.plist file. Create a file named.netrc
in your home directory if it doesn’t already exist, then add the following lines to the end of the file:machine api.mapbox.com login mapbox password PRIVATE_MAPBOX_API_TOKEN
where PRIVATE_MAPBOX_API_TOKEN is your Mapbox API token with the
DOWNLOADS:READ
scope.Create a Podfile with the following specification:
# Latest stable release pod 'MapboxNavigation', '~> 2.0' # Latest prerelease pod 'MapboxCoreNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :tag => 'v2.0.0' pod 'MapboxNavigation', :git => 'https://github.com/mapbox/mapbox-navigation-ios.git', :tag => 'v2.0.0'
Run
pod repo update && pod install
and open the resulting Xcode workspace.
Configuration
Mapbox APIs and vector tiles require a Mapbox account and API access token. In the project editor, select the application target, then go to the Info tab. Under the “Custom iOS Target Properties” section, set
MBXAccessToken
to your access token. You can obtain an access token from the Mapbox account page. Usage of Mapbox APIs is billed together based on monthly active users (MAU) rather than individually by HTTP request.In order for the SDK to track the user’s location as they move along the route, set
NSLocationWhenInUseUsageDescription
to:Shows your location on the map and helps improve the map.
Users expect the SDK to continue to track the user’s location and deliver audible instructions even while a different application is visible or the device is locked. Go to the Signing & Capabilities tab. Under the Background Modes section, enable “Audio, AirPlay, and Picture in Picture” and “Location updates”. (Alternatively, add the
audio
andlocation
values to theUIBackgroundModes
array in the Info tab.)
Now import the relevant modules and present a new NavigationViewController
. You can also push to a navigation view controller from within a storyboard if your application’s UI is laid out in Interface Builder.
import MapboxDirections
import MapboxCoreNavigation
import MapboxNavigation
// Define two waypoints to travel between
let origin = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 38.9131752, longitude: -77.0324047), name: "Mapbox")
let destination = Waypoint(coordinate: CLLocationCoordinate2D(latitude: 38.8977, longitude: -77.0365), name: "White House")
// Set options
let routeOptions = NavigationRouteOptions(waypoints: [origin, destination])
// Request a route using MapboxDirections
Directions.shared.calculate(routeOptions) { [weak self] (session, result) in
switch result {
case .failure(let error):
print(error.localizedDescription)
case .success(let response):
guard let strongSelf = self else {
return
}
// Pass the generated route response to the the NavigationViewController
let viewController = NavigationViewController(for: response, routeIndex: 0, routeOptions: routeOptions)
viewController.modalPresentationStyle = .fullScreen
strongSelf.present(viewController, animated: true, completion: nil)
}
}
Starting points
This SDK is divided into two frameworks: the Mapbox Navigation framework (MapboxNavigation
) is the ready-made turn-by-turn navigation UI, while the Mapbox Core Navigation framework (MapboxCoreNavigation
) is responsible for the underlying navigation logic.
Mapbox Navigation
NavigationViewController
is the main class that encapsulates the entirety of the turn-by-turn navigation UI, orchestrating the map view, various UI elements, and the route controller. Your application would most likely present an instance of this class. The NavigationViewControllerDelegate
protocol allows your application to customize various aspects of the UI and react to location-related events as they occur.
NavigationMapView
is the map view at the center of the turn-by-turn navigation UI. You can also use this class independently of NavigationViewController
, for example to display a route preview map. The NavigationMapViewDelegate
protocol allows your application to customize various aspects of the map view’s appearance. PassiveLocationProvider
is an optional alternative to CLLocationManager
for use with any standalone MapView
or NavigationMapView
.
CarPlayManager
is the class that manages the CarPlay screen if your application is CarPlay-enabled. It provides a main map for browsing, a search interface that can be powered by the Mapbox Search SDK for iOS or MapboxGeocoder.swift, and a turn-by-turn navigation UI similar to the one provided by NavigationViewController
. Your UIApplicationDelegate
subclass can conform to the CarPlayManagerDelegate
protocol to manage handoffs between NavigationViewController
and the CarPlay device, as well as to customize some aspects of the CarPlay navigation experience. To take advantage of CarPlay functionality, your application must have a CarPlay navigation application entitlement and be built in Xcode 10 or above, and the user’s iPhone or iPad must have iOS 12 or above installed.
Core Navigation
MapboxNavigationService
is responsible for receiving user location updates and determining their relation to the route line. If you build a completely custom navigation UI, this is the class your code would interact with directly. The NavigationServiceDelegate
protocol allows your application to react to location-related events as they occur. Corresponding Notification
s from the NavigationService
‘s RouteController
are also posted to the shared NotificationCenter
. These notifications indicate the current state of the application in the form of a RouteProgress
object.
For further details, consult the guides and examples included with this API reference. If you have any questions, please see our help page. We welcome your bug reports, feature requests, and contributions.
Changes in version 2.0.0
Packaging
- Choose from two new pricing options depending on your use case: per-trip or unlimited trips. (#3147, #3338)
- The Mapbox Navigation SDK for iOS license has changed from the ISC License to the Mapbox Terms of Service. (#2808)
- To gain access to Mapbox server APIs, set
MBXAccessToken
in your Info.plist.MGLMapboxAccessToken
is deprecated and no longer supported byNavigationMapView
. (#2837) - The
MBXNavigationBillingMethod
Info.plist key is no longer supported. (#3147)
System requirements
- MapboxNavigation and MapboxCoreNavigation require iOS 11.0 or above to run. iOS 10.x is no longer supported. (#2808)
- Xcode 12.4 or above is now required for building this SDK from source.
- You can build MapboxNavigation for an iOS simulator on an Apple Silicon–powered Mac. (#3031)
- You can now install MapboxNavigation using Swift Package Manager, but you can no longer install it using Carthage. If you previously installed MapboxNavigation using Carthage, use Swift Package Manager instead. (#2808)
- Carthage v0.38 or above is now required for installing this SDK if you use Carthage. (#3031)
- Added a Castilian Spanish localization. (#3186)
Dependencies
- MapboxNavigation now depends on MapboxMaps v10.x instead of Mapbox Maps SDK for iOS v6.x. Consult the “Migrate to v10” guide for tips on upgrading your runtime styling and other map-related code. (#3413)
- MapboxNavigation now depends on MapboxSpeech v2.x. (#3500)
- MapboxCoreNavigation no longer depends on MapboxAccounts. If you previously installed MapboxCoreNavigation using Carthage, remove MapboxAccounts.framework from your application’s Link Binary With Libraries build phase. (#2829)
- MapboxCoreNavigation now depends on MapboxMobileEvents v1.x. The dependency on MapboxMobileEvents is subject to change or removal in a future minor release of MapboxCoreNavigation, so your Podfile, Cartfile, or Package.swift should not explicitly depend on MapboxMobileEvents. (#3320)
- MapboxCoreNavigation now depends on MapboxDirections v2.x. (#3500)
- MapboxCoreNavigation now depends on Turf v2.x. (#3413)
- MapboxCoreNavigation now depends on MapboxNavigationNative v69.x. (#3413)
- MapboxCoreNavigation now depends on MapboxCommon v20.x. (#3413)
- Removed the optional dependency on MapboxGeocoder.swift. (#2999, #3183)
Map
NavigationMapView
is no longer a subclass ofMGLMapView
. To accessMGLMapView
properties and methods, use theNavigationMapView.mapView
property. (#2808)- Added the
NavigationOptions.navigationMapView
property for reusing a custom map view withinNavigationViewController
. (#3186). - Added the
NavigationMapView(frame:navigationCameraType:tileStoreLocation:)
initializer. (#2826) - Replaced the
NavigationMapView.navigationMapDelegate
andNavigationMapView.navigationMapViewDelegate
properties with a singleNavigationMapView.delegate
property. (#2808) - Renamed the
NavigationViewController.mapView
property toNavigationViewController.navigationMapView
. (#2808) - Renamed the
MGLStyle.navigationDayStyleURL
andMGLStyle.navigationNightStyleURL
properties toStyleURI.navigationDay
andStyleURI.navigationNight
, respectively. Removed theMGLStyle.navigationDayStyleURL(version:)
andMGLStyle.navigationNightStyleURL(version:)
methods in favor of these renamed properties. (#3332) - Renamed the
NavigationMapView.highlightBuildings(at:in3D:)
method toNavigationMapView.highlightBuildings(at:in3D:completion:)
. (#2827)
Camera
- Added the
NavigationMapView.navigationCamera
andNavigationCamera.cameraStateTransition
properties for controlling the camera’s motion and theNavigationViewportDataSource
class for configuring the viewport behavior based on the current location and nearby portions of the route line. Added theViewportDataSource
andCameraStateTransition
protocols and theNavigationViewportDataSourceOptions
struct for more granular customization. (#2826, #2944) - Removed the
CarPlayNavigationViewController.tracksUserCourse
property and theNavigationMapView.enableFrameByFrameCourseViewTracking(for:)
,NavigationMapView.updateCourseTracking(location:camera:animated:)
,NavigationMapView.setOverheadCameraView(from:along:for:)
, andNavigationMapView.recenterMap()
methods in favor of theNavigationMapView.navigationCamera
property. (#2826) - Removed the
NavigationMapView.defaultAltitude
,NavigationMapView.zoomedOutMotorwayAltitude
,NavigationMapView.longManeuverDistance
,NavigationMapView.defaultPadding
,NavigationMapView.courseTrackingDelegate
, andNavigationViewController.pendingCamera
properties and theNavigationMapViewDelegate.navigationMapViewUserAnchorPoint(_:)
method in favor of theNavigationCamera.cameraStateTransition
property. (#2826) NavigationMapView.updateCourseTracking(location:camera:animated:)
accepts aCameraOptions
instance instead of anMGLMapCamera
object. (#2808)- Changed the
NavigationViewController.pendingCamera
property’s type fromMGLMapCamera
toCameraOptions
. (#2808) - Renamed the
CourseUpdatable.update(location:pitch:direction:animated:tracksUserCourse:)
method toCourseUpdatable.update(location:pitch:direction:animated:navigationCameraState:)
. (#2826) - Eliminated redundant camera animations to conserve power. (#3155, #3172)
- Fixed the camera shaking in mobile and CarPlay during active navigation in simulation mode. (#3393)
User location indicator
- Removed the
NavigationMapView.showsUserLocation
andNavigationMapView.tracksUserCourse
properties in favor ofNavigationMapView.userLocationStyle
. (#2808) - Added the
NavigationMapView.userLocationStyle
property to customize how the user’s current location is displayed on the map. Set this property toUserLocationStyle.puck2D(configuration:)
orUserLocationStyle.puck3D(configuration:)
to use a location indicator layer (LayerType.locationIndicator
) powered by the Mapbox Maps SDK instead of the default view-backed implementation. (#2968) - Removed the
NavigationMapView.userCourseView
property in favor of the associated value whenNavigationMapView.userLocationStyle
is set toUserLocationStyle.courseView(_:)
. AddedNavigationMapView.reducedAccuracyActivatedMode
property, which allows to control current location styling based on accuracy authorization permission on iOS 14 and above. (#2968, #3384) - If you need to customize the appearance of the user location indicator, you can subclass
UserPuckCourseView
andUserHaloCourseView
as a starting point. (#2968) - Added the
UserHaloCourseView.haloBorderWidth
property for changing the width of the ring around the halo view. (#3309) - Fixed an issue where setting
UserPuckCourseView.puckColor
in aStyle
subclass had no effect. (#3306) - Fixed a memory leak in
UserCourseView
. (#3120) - Fixed the pitch issue of
UserHaloCourseView
when map tilted during active guidance navigation. (#3407) - Added the
UserPuckCourseView.minimizesInOverview
property, which allows to disableUserPuckCourseView
minimization in case when navigation camera state isNavigationCameraState.overview
. (#3460)
Route overlay
- Removed the
NavigationAnnotation
class. (#2808) - Renamed the
MBRouteLineWidthByZoomLevel
property toConstants.RouteLineWidthByZoomLevel
and changed its type toDouble
for keys and values. (#2808) - Renamed the
MBCurrentLegAttribute
andMBCongestionAttribute
constants toConstants.CurrentLegAttribute
andConstants.CongestionAttribute
, respectively. (#2808) - Added the
NavigationMapView.navigationMapView(_:didAdd:pointAnnotationManager:)
andNavigationViewController.navigationViewController(_:didAdd:pointAnnotationManager:)
delegate methods, which are called whenever aPointAnnotation
is added to aNavigationMapView
orNavigationViewController
, respectively, to represent the final destination. Added theNavigationMapView.pointAnnotationManager
property for managing point annotations. (#2961, #3109) - When specifying the
legIndex
inNavigationMapView.show(_:legIndex:)
, the route line for the specific route leg shows color-coded congestion segments, while other route legs are stroked withNavigationMapView.routeCasingColor
by default. If the leg index is unspecified, all the route legs show color-coded congestion. During turn-by-turn navigation, the default specified route leg is the current route leg. You can override the route leg colors using properties such asNavigationMapView.routeCasingColor
andNavigationMapView.trafficHeavyColor
. Added theNavigationMapView.showsCongestionForAlternativeRoutes
property to show congestion levels with different colors on alternative route lines. (#2833, #2887) - Fixed an issue where the route line disappears when changing a
NavigationMapView
’s style. (#3136) - Renamed the
NavigationMapView.updateRoute(_:)
method toNavigationMapView.travelAlongRouteLine(to:)
. Improved the performance of updating the route line to change color at the user’s location as they progress along the route. (#3201). - Fixed an issue where the route line grows backwards when the
NavigationViewController.routeLineTracksTraversal
property is set totrue
and the user passes the destination. (#3255) - Fixed incorrect color-coded traffic congestion along the route line and incorrect speeds in the speed limit view after some time had elapsed after rerouting. (#3344)
- By default, there is no longer a subtle crossfade between traffic congestion segments along a route line. To reenable this crossfade, set the
NavigationMapView.crossfadesCongestionSegments
property totrue
. You can also adjust the length of this crossfade using the global variableGradientCongestionFadingDistance
. (#3153, #3307) - The duration annotations added by the
NavigationMapView.showRouteDurations(along:)
method are now set in the fonts you specify using theNavigationMapView.routeDurationAnnotationFontNames
property. Use this property to specify a list of fallback fonts for better language support. (#2873) - Fixed an issue when route line was sometimes invisible after starting turn-by-turn navigation. (#3205)
Banners and guidance instructions
- Removed the
InstructionsBannerViewDelegate.didDragInstructionsBanner(_:)
method. (#2808) - Removed the
StatusView.delegate
andStatusView.canChangeValue
properties and theStatusViewDelegate
andDeprecatedStatusViewDelegate
protocols. (#2993) - Removed the
BottomBannerViewController(delegate:)
initializer. (#2993) - The top banner can now show a wider variety of turn lane configurations, such as combination U-turn/left turn lanes and combination through/slight right turn lanes. (#2882)
- Fixed an issue where the current road name label flashed when the camera state changed or the user traveled onto an unnamed road. (#2958)
- Fixed an issue where the current road name label sometimes displayed the name of an intersecting road instead of the current road or blinked in and out. (#3257)
- Fixed an issue where lane guidance icons would sometimes highlight the wrong arrow. (#2942)
- Fixed an issue where instruction banners could appear in the wrong color after switching between
Style
s. (#2977) - Fixed an issue where
GenericRouteShield
images would ignore changing its foreground color in favor of a cached image. (#3217) - Fixed an issue where some banner instructions were occasionally skipped. (#3265)
- Improved the current road name label’s performance and fixed a potential crash when updating it. (#3340)
- Fixed an issue where arrival guidance card appears too early. (#3383)
- Fixed an issue where the noncurrent guidance cards were highlighted. (#3442)
- Fixed an issue where guidance cards for multi-leg routes could temporarily show fewer cards than available. (#3451)
Location tracking
- Added the
NavigationLocationProvider
class to conform toLocationProvider
protocol, which depends onNavigationLocationManager
to detect the user’s location as it changes during turn-by-turn navigation.SimulatedLocationManager
andReplayLocationManager
can now be used with a standaloneNavigationMapView
throughNavigationMapView.mapView.location.overrideLocationProvider(with:)
. (#3091) - Added the
Notification.Name.currentRoadNameDidChange
to detect the road name posted byRouteController
. (#3266) RouteController
andPassiveLocationManager
now conform to theNavigationHistoryRecording
protocol, which has methods for recording details about a trip for debugging purposes. (#3157, #3448)- Renamed the
RouterDataSource.locationProvider
andEventsManagerDataSource.locationProvider
properties toRouterDataSource.locationManagerType
andActiveNavigationEventsManagerDataSource.locationManagerType
, respectively. (#3199) - Renamed the
Router.advanceLegIndex()
method toRouter.advanceLegIndex(completionHandler:)
and thePassiveLocationDataSource.updateLocation(_:)
method toPassiveLocationManager.updateLocation(_:completionHandler:)
. These methods are now asynchronous, and their completion handlers indicate whether the operation succeeded. (#3342) - Removed the
RouteLegProgress.upComingStep
property. (#2993) - Removed the
NavigationViewController.indexedRoute
,NavigationService.indexedRoute
, andRouter.indexedRoute
properties in favor ofNavigationViewController.indexedRouteResponse
,NavigationService.indexedRouteResponse
, andRouter.indexedRouteResponse
, respectively. Removed theRouteProgress.indexedRoute
property. (#3182) - The
NavigationViewController.indexedRoute
,NavigationService.indexedRoute
,Router.indexedRoute
, andRouteController.routeProgress
properties are no longer writable. Use theRouter.updateRoute(with:routeOptions:completion:)
method to manually reroute the user. (#3159, #3345, #3432) - The
NavigationService.router
andMapboxNavigationService.router
properties are no longer unsafe-unowned. (#3055) - Fixed unnecessary rerouting when calling the
NavigationService.start()
method. (#3239) - Fixed an issue where
RouteController
orPassiveLocationManager
sometimes snapped the user’s location assuming a path that violated a turn restriction. (#2808) - Added
SimulationMode.inTunnels
to enable simulating user location when loosing GPS signal while traversing tunnels. Simulation mode for default navigation service now can be configured usingNavigationOptons.simulationMode
. (#3314) - Improved performance and decreased memory usage when downloading routing tiles. (#2808)
- Fixed a crash when navigating along a route 0 meters long (for example, because two waypoints snap to the same location). (#3387)
- Renamed the
Router.updateRoute(with:routeOptions:)
method toRouter.updateRoute(with:routeOptions:completion:)
. The method is now asynchronous, with a new completion handler that is called when the update has completed. (#3432) - Fixed an issue where
RouteController
sometimes incorrectly reported the user’s location as being off-route. (#3432) - Fixed a crash due to an invalid
RouteProgress
object. (#3432)
Passive navigation
- Renamed
PassiveLocationManager
toPassiveLocationProvider
andPassiveLocationDataSource
toPassiveLocationManager
for consistency withNavigationLocationProvider
andNavigationLocationManager
. (#3091) PassiveLocationProvider
now conforms to theLocationProvider
protocol instead ofMGLLocationManager
. (#2808)- The
PassiveLocationProvider.delegate
property is now of typeLocationProviderDelegate
instead ofMGLLocationManagerDelegate
. (#2808) - Replaced
PassiveLocationManager.accuracyAuthorization()
was replaced with thePassiveLocationProvider.accuracyAuthorization
property, which now returnsCLAccuracyAuthorization
instead ofMBNavigationAccuracyAuthorization
. (#2808) - Fixed a potential hang when
PassiveLocationManager
fails to download routing tiles. (#2808) - Renamed
PassiveLocationManager.startUpdatingLocation(completionHandler:)
toPassiveLocationProvider.startUpdatingLocation()
. This method now runs synchronously likeCLLocationManager.startUpdatingLocation()
. (#2823)
Rerouting
RouteOptions
no longer conforms toNSCopying
. UseJSONEncoder
andJSONDecoder
to get a copy of theRouteOptions
object round-tripped through JSON. (#3484)- Added the
NavigationViewControllerDelegate.navigationViewController(_:shouldPreventReroutesWhenArrivingAt:)
method, which is called each time the user arrives at a waypoint. By default, this method returns true and prevents rerouting upon arriving. (#3195) - Renamed
RouteOptions.without(waypoint:)
toRouteOptions.without(_:)
. (#3192) - Rerouting now uses a snapped location instead of a raw location from Core Location. (#3361)
- Fixed an issue where a subclass of
NavigationRouteOptions
would turn into an ordinaryRouteOptions
when rerouting the user. (#3192, #3484) - Fixed an issue where the
RouteController.indexedRouteResponse
property would remain unchanged after the user is rerouted. (#3344) - Fixed an issue where the
IndexedRouteResponse.routeIndex
of theNavigationService.indexedRouteResponse
property would reset to zero after the user is rerouted. (#3345) - Fixed an issue where the user would be rerouted even if
NavigationViewControllerDelegate.navigationViewController(_:shouldRerouteFrom:)
returnedfalse
. To implement reroute after arrival behavior, returntrue
from this method andfalse
fromNavigationViewControllerDelegate.navigationViewController(_:shouldPreventReroutesWhenArrivingAt:)
, then setNavigationViewController.showsEndOfRouteFeedback
tofalse
. (#3195)
Predictive caching and offline navigation
- A new predictive cache proactively fetches tiles which may become necessary if the device loses its Internet connection at some point during passive or active turn-by-turn navigation. Pass a
PredictiveCacheOptions
instance into theNavigationOptions(styles:navigationService:voiceController:topBanner:bottomBanner:predictiveCacheOptions:)
initializer as you configure aNavigationViewController
, or manually callNavigationMapView.enablePredictiveCaching(options:)
. (#2830) - Added the
Directions.calculateOffline(options:completionHandler:)
andDirections.calculateWithCache(options:completionHandler:)
methods, which incorporate routing tiles from the predictive cache when possible to avoid relying on a network connection to calculate the route.RouteController
now also uses the predictive cache when rerouting. (#2848) - Fixed an issue where
PassiveLocationManager
andRouteController
did not use the access token and host specified byPassiveLocationDataSource.directions
andRouteController.directions
, respectively. Added thePredictiveCacheOptions.credentials
property for specifying the access token and host used for prefetching resources. (#2876) - Added the
NavigationMapView.mapTileStore
,PassiveLocationManager.navigatorTileStore
andRouteController.navigatorTileStore
properties for accessingTileStore
objects that are responsible for downloading map and routing tiles. (#2955) - Added the
TilesetDescriptorFactory
class for checking routing tiles in aTileStore
. The tile storage location is determined by theNavigationSettings.tileStoreConfiguration
property. (#3015, #3164, #3215) - Added the
Notification.Name.navigationDidSwitchToFallbackVersion
andNotification.Name.navigationDidSwitchToTargetVersion
notifications, which are posted whenPassiveLocationManager
andRouteController
fall back to an older set of navigation tiles present in the current tile storage. (#3014) - Added the
NavigationSettings.directions
andNavigationSettings.tileStoreConfiguration
properties for ensuring consistent caching between instances ofPassiveLocationManager
andRouteController
. Thedirections
argument ofPassiveLocationManager(directions:systemLocationManager:)
,RouteController(alongRouteAtIndex:in:options:directions:dataSource:)
, andMapboxNavigationService(routeResponse:routeIndex:routeOptions:directions:locationSource:eventsManagerType:simulating:routerType:)
now defaults toNavigationSettings.directions
. (#3215) - Removed
Bundle.ensureSuggestedTileURLExists()
,Bundle.suggestedTileURL
andBundle.suggestedTileURL(version:)
. (#3425)
Electronic horizon and route alerts
- While a
RouteController
,PassiveLocationProvider
, orPassiveLocationManager
is tracking the user’s location, you can get notifications about location changes that indicate relevant details in the electronic horizon – the upcoming portion of the routing graph – such as the names of cross streets and upcoming speed limit changes. To receive this information callRouteController.startUpdatingElectronicHorizon(with:)
orPassiveLocationManager.startUpdatingElectronicHorizon(with:)
methods and observe theNotification.Name.electronicHorizonDidUpdatePosition
,Notification.Name.electronicHorizonDidEnterRoadObject
,Notification.Name.electronicHorizonDidExitRoadObject
, andNotification.Name.electronicHorizonDidPassRoadObject
notifications. Use theRouteController.roadGraph
orPassiveLocationManager.roadGraph
property to get more information about the edges contained in these notifications. (#2834) - Note: The Mapbox Electronic Horizon feature of the Mapbox Navigation SDK is in public beta and is subject to changes, including its pricing. Use of the feature is subject to the beta product restrictions in the Mapbox Terms of Service. Mapbox reserves the right to eliminate any free tier or free evaluation offers at any time and require customers to place an order to purchase the Mapbox Electronic Horizon feature, regardless of the level of use of the feature.
- Added the
RouteController.roadObjectMatcher
andPassiveLocationManager.roadObjectMatcher
properties for creating user-defined road objects by matching location primitives to the road graph. (#3004) - Removed the
Alert
enumeration and theRouteAlert.alert
,RouteAlert.distance
,RouteAlert.length
,RouteAlert.beginCoordinate
,RouteAlert.endCoordinate
,RouteAlert.beginSegmentIndex
, andRouteAlert.endSegmentIndex
properties in favor of a consolidatedRouteAlerts.roadObject
property. (#2991) - Added the
RouteController.startUpdatingElectronicHorizon(with:)
,RouteController.stopUpdatingElectronicHorizon()
,PassiveLocationManager.startUpdatingElectronicHorizon(with:)
andPassiveLocationManager.stopUpdatingElectronicHorizon()
methods for managing electronic horizon updates. By default electronic horizon updates are disabled. (#3475)
CarPlay
- Removed the
CarPlayNavigationDelegate.carPlayNavigationViewControllerDidArrive(_:)
method. (#2808) - Renamed the
CarPlayManager.mapView
property toCarPlayManager.navigationMapView
. (#2808) - Removed the
CarPlayManager.overviewButton
property. (#2808) - Removed the
CarPlayNavigationViewController.drivingSide
property. (#2808) - Added the
CarPlayManagerDelegate.carPlayManager(_:shouldPresentArrivalUIFor:)
andCarPlayNavigationViewController.navigationService(_:didArriveAt:)
methods for determining when to present an arrival user interface. (#3016) - Renamed the
CarPlayNavigationDelegate
protocol toCarPlayNavigationViewControllerDelegate
and theCarPlayNavigationViewController.carPlayNavigationDelegate
property toCarPlayNavigationViewController.delegate
. (#3036) - The
CarPlayNavigationViewController.styleManager
andCarPlayMapViewController.styleManager
properties are now read-only. (#3137) - Moved the
CarPlaySearchController.searchTemplate(_:updatedSearchText:completionHandler:)
,CarPlaySearchController.searchTemplate(_:searchTemplate:selectedResult:completionHandler:)
methods to theCarPlaySearchControllerDelegate
protocol. Renamed theCarPlaySearchControllerDelegate.resultsOrNoResults(_:limit:)
method toCarPlaySearchControllerDelegate.searchResults(with:limit:)
. (#2999) CarPlaySearchControllerDelegate
now conforms to theCPSearchTemplateDelegate
protocol. (#2999)- Added the
NavigationGeocodedPlacemark
struct, which is similar to MapboxGeocoder.swift’sGeocodedPlacemark
struct but with the addition of theNavigationGeocodedPlacemark.listItem()
method. Added theRecentItem
struct to represent a recently selected search result. (#2999) - Added the
CarPlayMapViewControllerDelegate
protocol, which provides methods for reacting to events during the browsing and previewing activities. (#3190) - Added the
CarPlayMapViewControllerDelegate.carPlayMapViewController(_:didAdd:pointAnnotationManager:)
,CarPlayNavigationViewControllerDelegate.carPlayNavigationViewController(_:didAdd:pointAnnotationManager:)
andCarPlayManager.carPlayManager(_:didAdd:to:pointAnnotationManager:)
delegate methods, which will be called whenever thePointAnnotation
representing the final destination is added toCarPlayMapViewController
,CarPlayNavigationViewController
andCarPlayManager
, respectively. (#3190) - A speed limit indicator now appears on the map during the browsing activity. (#3197)
- A speed limit indicator now can be fully hidden by using
SpeedLimitView.isAlwaysHidden
property. (#3429) - Renamed the
CarPlayManagerDelegate.carPlayManager(_:navigationServiceAlong:routeIndex:routeOptions:desiredSimulationMode:)
method toCarPlayManagerDelegate.carPlayManager(_:navigationServiceFor:routeIndex:routeOptions:desiredSimulationMode:)
. It now returns an optionalNavigationService
; if it isnil
, aMapboxNavigationService
will be used by default. (#3208) - Renamed the
CarPlayManagerDelegate.carplayManagerShouldDisableIdleTimer(_:)
method toCarPlayManagerDelegate.carPlayManagerShouldDisableIdleTimer(_:)
. (#3208) - Added the
CarPlayManagerDelegate.carPlayManager(_:templateWillAppear:animated:)
,CarPlayManagerDelegate.carPlayManager(_:templateDidAppear:animated:)
,CarPlayManagerDelegate.carPlayManager(_:templateWillDisappear:animated:)
, andCarPlayManagerDelegate.carPlayManager(_:templateDidDisappear:animated:)
methods to pass through the corresponding methods fromCPInterfaceControllerDelegate
. (#3219) - Fixed an issue where
CPMapTemplate.tripEstimateStyle
uses dark appearance even if light appearance is selected. (#3397) CarPlayMapViewController
andCarPlayNavigationViewController
are now subclassable. (#3424)- Added
CPInterfaceController.safePopTemplate(animated:)
, which allows to safely pop back aCPTemplate
by a single level in the template navigation hierarchy. (#3426)
User feedback
- You can now solicit user feedback about
PassiveLocationManager
andNavigationMapView
outside of active turn-by-turn navigation. UsePassiveLocationManager.eventsManager
property ofNavigationEventsManager
type to create and send user feedback. You can use aFeedbackViewController
to present the user with the same options as during turn-by-turn navigation. Alternatively, if you present a custom feedback UI, call theNavigationEventsManager.createFeedback()
method and configure the resultingFeedbackEvent
with any additional context. (#3122, #3322) - The
ActiveNavigationEventsManagerDataSource.router
,NavigationService.eventsManager
, andMapboxNavigationService.eventsManager
properties are no longer unsafe-unowned. (#3055) - Removed the
EventsManager
type alias. (#2993) - Feedback events now include a snapshot of
NavigationViewController
that is taken sooner, when the problem is more likely to be apparent. (#3049) - You can now manage the feedback event lifecycle, allowing the user to submit additional details later. Use
NavigationEventsManager.createFeedback()
to create aFeedbackEvent
andNavigationEventsManager.sendActiveNavigationFeedback(_:type:description:)
to send it to Mapbox.FeedbackEvent
conforms to theCodable
protocol, so your application can store incomplete feedback across sessions if necessary. (#3154, #3318) - To submit feedback during passive navigation, use
NavigationEventsManager.createFeedback()
to create aFeedbackEvent
andNavigationEventsManager.sendPassiveNavigationFeedback(_:type:description:)
to send it to Mapbox. This method acceptsPassiveNavigationFeedbackType
with feedback types specific to the passive navigation. (#3154, #3318) - Added an optional
NavigationEventsManager.userInfo
property that can be sent with all navigation events. The new property can contain application metadata, such as the application name and version, that is included in each event to help Mapbox triage and diagnose unexpected behavior. (#3007). - Fixed a missing feedback subtype description for
LooksIncorrectSubtype.incorrectSpeedLimit
and all “other” subtypes. (#3238) - Renamed the
FeedbackViewController(eventsManager:)
initializer toFeedbackViewController(eventsManager:type:)
. You can now customize the view controller to show only the feedback types specific to passive navigation. (#3323) - Renamed the
FeedbackType
enumeration toActiveNavigationFeedbackType
and theEventsManagerDataSource
protocol toActiveNavigationEventsManagerDataSource
. (#3327) - Renamed the user-facing feedback categories and subcategories for active turn-by-turn navigation that are represented at runtime by the
ActiveNavigationFeedbackType
enumeration. (#3339 - Added the ability to pass your own screenshot to the
NavigationEventsManager.createFeedback()
when a user submits a feedback. Screenshots help Mapbox to determine where issues exist for review and correction. (#3380 - Added
NavigationEventsManager.sessionId
, which allows getting session identifier used in feedback and other events. (#3449)
Other changes
- If your storyboard has a segue to
NavigationViewController
in Navigation.storyboard, you have to call theNavigationViewController.prepareViewLoading(routeResponse:routeIndex:routeOptions:navigationOptions:)
method in your implementation of theUIViewController.prepare(for:sender:)
method. (#2974, #3182) - Removed the
NavigationViewController.origin
property. (#2808) - Fixed a potential memory leak when using
MultiplexedSpeechSynthesizer
. (#3005) - Fixed a thread-safety issue in
UnimplementedLogging
protocol implementation. (#3024) - Fixed an issue where
UIApplication.shared.isIdleTimerDisabled
was not properly set in some cases. (#3245) - Fixed an issue where
LegacyRouteController
could not correctly handle arrival to the intermediate waypoint of a multi leg route. (#3483) - Added the
Notification.Name.navigationServiceSimulationDidChange
to detect when the navigation service changes the simulating status, includingMapboxNavigationService.NotificationUserInfoKey.simulationStateKey
andMapboxNavigationService.NotificationUserInfoKey.simulatedSpeedMultiplierKey
. (#3393). - By default,
NavigationRouteOptions
requestsAttributeOptions.maximumSpeedLimit
attributes along the route with theDirectionsProfileIdentifier.walking
profile as with other profiles. (#3496)