-
A navigation service coordinates various nonvisual components that track the user as they navigate along a predetermined route. You use
MapboxNavigationService, which conforms to this protocol, either as part ofNavigationViewControlleror by itself as part of a custom user interface. A navigation service calls methods on itsdelegate, which conforms to theNavigationServiceDelegateprotocol, whenever significant events or decision points occur along the route.A navigation service controls a
NavigationLocationManagerfor determining the user’s location, aRouterthat tracks the user’s progress along the route, aMapboxRoutingProviderservice for calculating new routes (only used when rerouting), and aNavigationEventsManagerfor sending telemetry events related to navigation or user feedback.NavigationViewControllercomes with aMapboxNavigationServiceby default. You may override it to customize theMapboxRoutingProvider‘s source service or simulation mode. After creating the navigation service, pass it intoNavigationOptions(styles:navigationService:voiceController:topBanner:bottomBanner:), then pass that object intoNavigationViewController(for:options:).If you use a navigation service by itself, outside of
See moreNavigationViewController, callstart()when the user is ready to begin navigating along the route.Declaration
Swift
public protocol NavigationService : CLLocationManagerDelegate, ActiveNavigationEventsManagerDataSource, RouterDataSource -
A navigation service delegate interacts with one or more
NavigationServiceinstances (such asMapboxNavigationServiceobjects) during turn-by-turn navigation. This protocol is the main way that your application can synchronize its state with the SDK’s location-related functionality. Each of the protocol’s methods is optional.As the user progresses along a route, a navigation service informs its delegate about significant events as they occur, and the delegate has opportunities to influence the route and its presentation. For example, when the navigation service reports that the user has arrived at the destination, your delegate implementation could present information about the destination. It could also customize individual visual or spoken instructions along the route by returning modified instruction objects.
Assign a
NavigationServiceDelegateinstance to theNavigationService.delegateproperty of the navigation service before you start the service.The
RouterDelegateprotocol defines corresponding methods so that aRouterinstance can interact with an object that is both a router delegate and a navigation service, which in turn interacts with a navigation service delegate. Additionally, several location-related methods in this protocol have corresponding methods in theNavigationViewControllerDelegateprotocol, which can be convenient if you are using the navigation service in conjunction with aNavigationViewController. Normally, you would either implement methods inNavigationServiceDelegateorNavigationViewControllerDelegatebut notRouterDelegate.Seealso
NavigationViewControllerDelegateSee moreSeealso
RouterDelegateDeclaration
Swift
public protocol NavigationServiceDelegate : AnyObject, UnimplementedLogging -
A concrete implementation of the
NavigationServiceprotocol.NavigationViewControllercomes with aMapboxNavigationServiceby default. You may override it to customize theDirectionsservice or simulation mode. After creating the navigation service, pass it intoNavigationOptions(styles:navigationService:voiceController:topBanner:bottomBanner:), then pass that object intoNavigationViewController(for:options:).If you use a navigation service by itself, outside of
See moreNavigationViewController, callstart()when the user is ready to begin navigating along the route.Declaration
Swift
public class MapboxNavigationService : NSObject, NavigationServiceextension MapboxNavigationService: CLLocationManagerDelegateextension MapboxNavigationService: RouterDelegateextension MapboxNavigationService: ReplayManagerHistoryEventsListener -
A class conforming to the
Routerprotocol tracks the user’s progress as they travel along a predetermined route. It calls methods on itsdelegate, which conforms to theRouterDelegateprotocol, whenever significant events or decision points occur along the route. Despite its name, this protocol does not define the interface of a routing engine.There are two concrete implementations of the
See moreRouterprotocol.RouteController, the default implementation, is capable of client-side routing and depends on the Mapbox Navigation Native framework.LegacyRouteControlleris an alternative implementation that does not have this dependency but must be used in conjunction with the Mapbox Directions API over a network connection.Declaration
Swift
public protocol Router : CLLocationManagerDelegate -
A router data source, also known as a location manager, supplies location data to a
See moreRouterinstance. For example, aMapboxNavigationServicesupplies location data to aRouteControllerorLegacyRouteController.Declaration
Swift
public protocol RouterDataSource : AnyObject -
A
RouteControllertracks the user’s progress along a route, posting notifications as the user reaches significant points along the route. On every location update, the route controller evaluates the user’s location, determining whether the user remains on the route. If not, the route controller calculates a new route.RouteControlleris responsible for the core navigation logic whereasNavigationViewControlleris responsible for displaying a default drop-in navigation UI.Important
Creating an instance of this type will start an Active Guidance session. The trip session is stopped when the instance is deallocated. From more info read the Pricing Guide.See morePrecondition
There should be only oneRouteControlleralive to any given time.Declaration
Swift
open class RouteController : NSObjectextension RouteController: HistoryRecordingextension RouteController: Router -
A router delegate interacts with one or more
Routerinstances, such asRouteControllerobjects, during turn-by-turn navigation. This protocol is similar toNavigationServiceDelegate, which is the main way that your application can synchronize its state with the SDK’s location-related functionality. Normally, you should not need to make a class conform to theRouterDelegateprotocol or call any of its methods directly, but you would need to call this protocol’s methods if you implement a customRouterclass.MapboxNavigationServiceis the only concrete implementation of a router delegate. Implement theNavigationServiceDelegateprotocol instead to be notified when various significant events occur along the route tracked by aNavigationService.Seealso
MapboxNavigationServiceSee moreSeealso
NavigationServiceDelegateDeclaration
Swift
public protocol RouterDelegate : AnyObject, UnimplementedLogging -
See moreRouteProgressstores the user’s progress along a route.Declaration
Swift
open class RouteProgress : Codable -
See moreRouteLegProgressstores the user’s progress along a route leg.Declaration
Swift
open class RouteLegProgress : Codable -
See moreRouteStepProgressstores the user’s progress along a route step.Declaration
Swift
open class RouteStepProgress : Codable -
Declaration
Swift
extension CongestionLevel -
Declaration
Swift
extension VisualInstruction -
The
See moreVisualInstructionDelegateprotocol defines a method that allows an object to customize presented visual instructions.Declaration
Swift
public protocol VisualInstructionDelegate : AnyObject, UnimplementedLogging -
The
See moreNavigationEventsManageris responsible for being the liaison between MapboxCoreNavigation and the Mapbox telemetry.Declaration
Swift
open class NavigationEventsManager -
The
See moreActiveNavigationEventsManagerDataSourceprotocol declares values required for recording route following events.Declaration
Swift
public protocol ActiveNavigationEventsManagerDataSource : AnyObject -
A data source that declares values required for recording passive location events.
See moreDeclaration
Swift
public protocol PassiveNavigationEventsManagerDataSource : AnyObject -
See moreNavigationLocationManageris the base location manager which handles permissions and background modes.Declaration
Swift
open class NavigationLocationManager : CLLocationManagerextension NavigationLocationManager: RouterDataSource -
See moreReplayLocationManagerreplays an array of locations exactly as they were recorded with the single exception of the location’s timestamp which will be adjusted by interval between locations.Declaration
Swift
open class ReplayLocationManager : NavigationLocationManager -
The
SimulatedLocationManagerclass simulates location updates along a given route.The route will be replaced upon a
RouteControllerDidReroutenotification.The manager calls delegate methods on a background thread.
See moreDeclaration
Swift
open class SimulatedLocationManager : NavigationLocationManager -
A
NavigationRouteOptionsobject specifies turn-by-turn-optimized criteria for results returned by the Mapbox Directions API.NavigationRouteOptionsis a subclass ofRouteOptionsthat has been optimized for navigation. Pass an instance of this class into theDirections.calculate(_:completionHandler:)method.This class implements the
NSCopyingprotocol by round-tripping the object throughJSONEncoderandJSONDecoder. If you subclassNavigationRouteOptions, make sure any properties you add are accounted for inDecodable(from:)andEncodable.encode(to:). If your subclass contains any customizations that cannot be represented in JSON, make sure the subclass overridesNSCopying.copy(with:)to persist those customizations.
See moreNavigationRouteOptionsis designed to be used with theDirectionsandNavigationDirectionsclasses for specifying routing criteria. To customize the user experience in aNavigationViewController, use theNavigationOptionsclass.Declaration
Swift
open class NavigationRouteOptions : RouteOptions, OptimizedForNavigation -
Declaration
Swift
extension DirectionsOptions -
A
NavigationMatchOptionsobject specifies turn-by-turn-optimized criteria for results returned by the Mapbox Map Matching API.NavigationMatchOptionsis a subclass ofMatchOptionsthat has been optimized for navigation. Pass an instance of this class into theDirections.calculateRoutes(matching:completionHandler:).method.Note: it is very important you specify the
See morewaypointsfor the route. Usually the only two values for thisIndexSetwill be 0 and the length of the coordinates. Otherwise, all coordinates passed through will be considered waypoints.Declaration
Swift
open class NavigationMatchOptions : MatchOptions, OptimizedForNavigation -
The simulation mode type. Used for setting the simulation mode of the navigation service.
See moreDeclaration
Swift
public enum SimulationMode : Int -
The simulation intent type. Used for describing the intent to start simulation of the navigation service.
See moreDeclaration
Swift
public enum SimulationIntent : Int -
The simulation state type. Used for notifying users of the change of navigation service simulation status.
See moreDeclaration
Swift
public enum SimulationState : Int -
An object that notifies its delegate when the user’s location changes, minimizing the noise that normally accompanies location updates from a
CLLocationManagerobject.Unlike
Routerclasses such asRouteControllerandLegacyRouteController, this class operates without a predefined route, matching the user’s location to the road network at large. You can use a passive location manager to determine a starting point for a route that you calculate using theDirections.calculate(_:completionHandler:)method. If the user happens to be moving while you calculate the route, the passive location manager makes it less likely that the route will begin with a short segment on a side road or driveway and a confusing instruction to turn onto the current road.To find out when the user’s location changes, implement the
PassiveLocationManagerDelegateprotocol, or observeNotification.Name.passiveLocationManagerDidUpdatenotifications for more detailed information.See moreImportant
Creating an instance of this class will start a free-driving session. If the application goes into the background or you temporarily stop needing location updates for any other reason, temporarily pause the trip session using thePassiveLocationManager.pauseTripSession()method to avoid unnecessary costs. The trip session also stops when the instance is deinitialized. For more information, see the “Pricing” guide.Declaration
Swift
open class PassiveLocationManager : NSObjectextension PassiveLocationManager: HistoryRecordingextension PassiveLocationManager: CLLocationManagerDelegateextension PassiveLocationManager: PassiveNavigationEventsManagerDataSource -
A delegate of a
See morePassiveLocationManagerobject implements methods that the location manager calls as the user’s location changes.Declaration
Swift
public protocol PassiveLocationManagerDelegate : AnyObject
Install in Dash
Core Navigation Logic Reference