NavigationService
public protocol NavigationService : CLLocationManagerDelegate, ActiveNavigationEventsManagerDataSource, RouterDataSource
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 of NavigationViewController
or by itself as part of a custom user interface. A navigation service calls methods on its delegate
, which conforms to the NavigationServiceDelegate
protocol, whenever significant events or decision points occur along the route.
A navigation service controls a NavigationLocationManager
for determining the user’s location, a Router
that tracks the user’s progress along the route, a MapboxRoutingProvider
service for calculating new routes (only used when rerouting), and a NavigationEventsManager
for sending telemetry events related to navigation or user feedback.
NavigationViewController
comes with a MapboxNavigationService
by default. You may override it to customize the MapboxRoutingProvider
‘s source service or simulation mode. After creating the navigation service, pass it into NavigationOptions(styles:navigationService:voiceController:topBanner:bottomBanner:)
, then pass that object into NavigationViewController(for:options:)
.
If you use a navigation service by itself, outside of NavigationViewController
, call start()
when the user is ready to begin navigating along the route.
-
The location manager for the service. This will be the object responsible for notifying the service of GPS updates.
Declaration
Swift
var locationManager: NavigationLocationManager { get }
-
A reference to a MapboxDirections service. Used for rerouting.
Declaration
Swift
@available(*, deprecated, message: "Use `customRoutingProvider` instead. If navigation service was not initialized using `Directions` object - this property is unused and ignored.") var directions: Directions { get }
-
RoutingProvider
, used to create a route during refreshing or rerouting.Declaration
Swift
@available(*, deprecated, message: "Use `customRoutingProvider` instead. Nullable value now corresponds to SDK default behavior.") var routingProvider: RoutingProvider { get }
-
Custom
RoutingProvider
, used to create a route during refreshing or rerouting.Declaration
Swift
var customRoutingProvider: RoutingProvider? { get }
-
Credentials data, used to authorize server requests.
Declaration
Swift
var credentials: Credentials { get }
-
The router object that tracks the user’s progress as they travel along a predetermined route.
Declaration
Swift
var router: Router { get }
-
The events manager, responsible for all telemetry.
Declaration
Swift
var eventsManager: NavigationEventsManager { get }
-
The route along which the user is expected to travel.
If you want to update the route, use
Router.updateRoute(with:routeOptions:completion:)
method fromrouter
.Declaration
Swift
var route: Route { get }
-
The
RouteResponse
object containing active route, plus its index in thisRouteResponse
, if applicable.If you want to update the route, use
Router.updateRoute(with:routeOptions:completion:)
method fromrouter
.Declaration
Swift
var indexedRouteResponse: IndexedRouteResponse { get }
-
The simulation mode of the service.
Declaration
Swift
var simulationMode: SimulationMode { get set }
-
The simulation speed-multiplier. Modify this if you desire accelerated simulation.
Declaration
Swift
var simulationSpeedMultiplier: Double { get set }
-
The Amount of time the service will wait until it begins simulation in a poor GPS scenerio. Defaults to 2.5 seconds.
Declaration
Swift
var poorGPSPatience: Double { get set }
-
The navigation service’s delegate, which is informed of significant events and decision points along the route.
To synchronize your application’s state with the turn-by-turn navigation experience, set this property before starting the navigation session.
Declaration
Swift
var delegate: NavigationServiceDelegate? { get set }
-
Starts the navigation service.
Declaration
Swift
func start()
-
Stops the navigation service. You may call
start()
after callingstop()
.Declaration
Swift
func stop()
-
Ends the navigation session. Used when arriving at destination.
Declaration
Swift
func endNavigation(feedback: EndOfRouteFeedback?)
-
Interrogates the navigationService as to whether or not the passed-in location is in a tunnel.
Declaration
Swift
func isInTunnel(at location: CLLocation, along progress: RouteProgress) -> Bool