MapboxNavigationService
public class MapboxNavigationService : NSObject, NavigationService
extension MapboxNavigationService: CLLocationManagerDelegate
extension MapboxNavigationService: RouterDelegate
extension MapboxNavigationService: ReplayManagerHistoryEventsListener
A concrete implementation of the NavigationService
protocol.
NavigationViewController
comes with a MapboxNavigationService
by default. You may override it to customize the Directions
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 Amount of time the service will wait until it begins simulation in a poor GPS scenerio. Defaults to 2.5 seconds.
Declaration
Swift
public var poorGPSPatience: Double { get set }
-
The simulation mode of the service.
Declaration
Swift
public var simulationMode: SimulationMode { get set }
-
The simulation speed multiplier. If you desire the simulation to go faster than real-time, increase this value.
Declaration
Swift
public var simulationSpeedMultiplier: Double { get set }
-
Starts navigation service.
Whenever navigation service starts billing session is resumed. For more info regarding billing, read the Pricing Guide.
Declaration
Swift
public func start()
-
Stops navigation service. Navigation service can be resumed by calling
start()
after callingstop()
.Whenever navigation service stops billing session is paused. For more info regarding billing, read the Pricing Guide.
Declaration
Swift
public func stop()
-
Declaration
Swift
public func endNavigation(feedback: EndOfRouteFeedback? = nil)
-
init(routeResponse:routeIndex:routeOptions:directions:locationSource:eventsManagerType:simulating:routerType:)
Intializes a new
NavigationService
.Declaration
Swift
@available(*, deprecated, renamed: "init(indexedRouteResponse:customRoutingProvider:credentials:locationSource:eventsManagerType:simulating:routerType:customActivityType:userInfo:﹚") public convenience init(routeResponse: RouteResponse, routeIndex: Int, routeOptions: RouteOptions, directions: Directions? = nil, locationSource: NavigationLocationManager? = nil, eventsManagerType: NavigationEventsManager.Type? = nil, simulating simulationMode: SimulationMode? = nil, routerType: Router.Type? = nil)
Parameters
routeResponse
RouteResponse
object, containing selection of routes to follow.routeIndex
The index of the route within the original
RouteResponse
object.routeOptions
The route options used to get the route.
directions
The Directions object that created
route
. If this argument is omitted, the shared value ofNavigationSettings.directions
will be used.locationSource
An optional override for the default
NaviationLocationManager
.eventsManagerType
An optional events manager type to use while tracking the route.
simulationMode
The simulation mode desired.
routerType
An optional router type to use for traversing the route.
-
init(routeResponse:routeIndex:routeOptions:routingProvider:credentials:locationSource:eventsManagerType:simulating:routerType:)
Intializes a new
NavigationService
.Declaration
Swift
@available(*, deprecated, renamed: "init(indexedRouteResponse:customRoutingProvider:credentials:locationSource:eventsManagerType:simulating:routerType:customActivityType:userInfo:﹚") public convenience init(routeResponse: RouteResponse, routeIndex: Int, routeOptions: RouteOptions, routingProvider: RoutingProvider, credentials: Credentials, locationSource: NavigationLocationManager? = nil, eventsManagerType: NavigationEventsManager.Type? = nil, simulating simulationMode: SimulationMode? = nil, routerType: Router.Type? = nil)
Parameters
routeResponse
RouteResponse
object, containing selection of routes to follow.routeIndex
The index of the route within the original
RouteResponse
object.routeOptions
The route options used to get the route.
routingProvider
RoutingProvider
, used to create a route during refreshing or rerouting.credentials
Credentials to authorize additional data requests throughout the route.
locationSource
An optional override for the default
NaviationLocationManager
.eventsManagerType
An optional events manager type to use while tracking the route.
simulationMode
The simulation mode desired.
routerType
An optional router type to use for traversing the route.
-
init(routeResponse:routeIndex:routeOptions:customRoutingProvider:credentials:locationSource:eventsManagerType:simulating:routerType:customActivityType:)
Intializes a new
NavigationService
.Declaration
Swift
@available(*, deprecated, renamed: "init(indexedRouteResponse:customRoutingProvider:credentials:locationSource:eventsManagerType:simulating:routerType:customActivityType:userInfo:﹚") required public convenience init(routeResponse: RouteResponse, routeIndex: Int, routeOptions: RouteOptions, customRoutingProvider: RoutingProvider? = nil, credentials: Credentials, locationSource: NavigationLocationManager? = nil, eventsManagerType: NavigationEventsManager.Type? = nil, simulating simulationMode: SimulationMode? = nil, routerType: Router.Type? = nil, customActivityType: CLActivityType? = nil)
Parameters
routeResponse
RouteResponse
object, containing selection of routes to follow.routeIndex
The index of the route within the original
RouteResponse
object.routeOptions
The route options used to get the route.
customRoutingProvider
Custom
RoutingProvider
, used to create a route during refreshing or rerouting.credentials
Credentials to authorize additional data requests throughout the route.
locationSource
An optional override for the default
NaviationLocationManager
.eventsManagerType
An optional events manager type to use while tracking the route.
simulationMode
The simulation mode desired.
routerType
An optional router type to use for traversing the route.
customActivityType
Custom
CLActivityType
to be used for location updates. If not specified, SDK will pick it automatically for current navigation profile. -
init(indexedRouteResponse:customRoutingProvider:credentials:locationSource:eventsManagerType:simulating:routerType:customActivityType:userInfo:)
Intializes a new
NavigationService
.Declaration
Swift
required public init(indexedRouteResponse: IndexedRouteResponse, customRoutingProvider: RoutingProvider? = nil, credentials: Credentials, locationSource: NavigationLocationManager? = nil, eventsManagerType: NavigationEventsManager.Type? = nil, simulating simulationMode: SimulationMode? = nil, routerType: Router.Type? = nil, customActivityType: CLActivityType? = nil, userInfo: [String: String?]? = nil)
Parameters
indexedRouteResponse
IndexedRouteResponse
object, containing selection of routes to follow.customRoutingProvider
Custom
RoutingProvider
, used to create a route during refreshing or rerouting.credentials
Credentials to authorize additional data requests throughout the route.
locationSource
An optional override for the default
NaviationLocationManager
.eventsManagerType
An optional events manager type to use while tracking the route.
simulationMode
The simulation mode desired.
routerType
An optional router type to use for traversing the route.
customActivityType
Custom
CLActivityType
to be used for location updates. If not specified, SDK will pick it automatically for current navigation profile.userInfo
An optional metadata to be provided as initial value of
NavigationEventsManager.userInfo
property. -
init(history:customHistoryEventsListener:customRoutingProvider:credentials:eventsManagerType:routerType:customActivityType:userInfo:)
Intializes a new
NavigationService
for replaying a session from providedHistory
.Declaration
Swift
public convenience init?(history: History, customHistoryEventsListener: ReplayManagerHistoryEventsListener? = nil, customRoutingProvider: RoutingProvider? = nil, credentials: Credentials, eventsManagerType: NavigationEventsManager.Type? = nil, routerType: Router.Type? = nil, customActivityType: CLActivityType? = nil, userInfo: [String: String?]? = nil)
Parameters
history
History
object, containing initial route and location trace to be replayed.customHistoryEventsListener
Custom
ReplayManagerHistoryEventsListener
which will be used to handle replay events. Default value (nil
) will also loop route assignment events to update theRouter
.customRoutingProvider
Custom
RoutingProvider
, used to create a route during refreshing or rerouting.credentials
Credentials to authorize additional data requests throughout the route.
eventsManagerType
An optional events manager type to use while tracking the route.
routerType
An optional router type to use for traversing the route.
customActivityType
Custom
CLActivityType
to be used for location updates. If not specified, SDK will pick it automatically for current navigation profile.userInfo
An optional metadata to be provided as initial value of
NavigationEventsManager.userInfo
property.
-
The active location manager. Returns the location simulator if we’re actively simulating, otherwise it returns the native location manager.
Declaration
Swift
public var locationManager: NavigationLocationManager { get }
-
A reference to a MapboxDirections service. Used for rerouting.
Declaration
Swift
@available(*, deprecated, message: "Use `routingProvider` instead. If navigation service was not initialized using `Directions` object - this property is unused and ignored.") public lazy var directions: Directions { get set }
-
Custom
RoutingProvider
, used to create a route during refreshing or rerouting.Declaration
Swift
@available(*, deprecated, message: "Use `customRoutingProvider` instead. This property will be equal to `customRoutingProvider` if that is provided or a `MapboxRoutingProvider` instance otherwise.") public var routingProvider: RoutingProvider { get }
-
Custom
RoutingProvider
, used to create a route during refreshing or rerouting.If set to
nil
- default Mapbox implementation will be used.Declaration
Swift
public var customRoutingProvider: RoutingProvider? { get }
-
Credentials data, used to authorize server requests.
Declaration
Swift
public var credentials: Credentials
-
The
NavigationService
delegate. WrapsRouterDelegate
messages.Declaration
Swift
public weak var delegate: NavigationServiceDelegate?
-
The active router. By default, a
RouteController
.Declaration
Swift
public var router: Router { get }
-
The events manager. Sends telemetry back to the Mapbox platform.
Declaration
Swift
public var eventsManager: NavigationEventsManager { get }
-
Declaration
Swift
public var route: Route { get }
-
Declaration
Swift
public var indexedRouteResponse: IndexedRouteResponse { get }
-
Determines if a location is within a tunnel.
Declaration
Swift
public func isInTunnel(at location: CLLocation, along progress: RouteProgress) -> Bool
Parameters
location
The location to test.
progress
the RouteProgress model that contains the route geometry.
-
Declaration
Swift
public func updateRoute(with indexedRouteResponse: IndexedRouteResponse, routeOptions: RouteOptions?, completion: ((Bool) -> Void)?)
-
Keys in the user info dictionaries of various notifications posted by instances of
See moreNavigationService
.Declaration
Swift
public struct NotificationUserInfoKey : Hashable, Equatable, RawRepresentable
-
Declaration
Swift
public func locationManager(_ manager: CLLocationManager, didUpdateHeading newHeading: CLHeading)
-
Declaration
Swift
public func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation])
-
Declaration
Swift
public func locationManagerDidChangeAuthorization(_ manager: CLLocationManager)
-
Declaration
Swift
public func router(_ router: Router, willRerouteFrom location: CLLocation)
-
Declaration
Swift
public func router(_ router: Router, modifiedOptionsForReroute options: RouteOptions) -> RouteOptions
-
Declaration
-
Declaration
Swift
public func router(_ router: Router, didFailToRerouteWith error: Error)
-
Declaration
Swift
public func router(_ router: Router, didRefresh routeProgress: RouteProgress)
-
Declaration
Swift
public func routerDidFailToRefreshExpiredRoute(_ router: any Router)
-
Declaration
Swift
public func router(_ router: Router, didUpdate progress: RouteProgress, with location: CLLocation, rawLocation: CLLocation)
-
Declaration
Swift
public func router(_ router: Router, didPassVisualInstructionPoint instruction: VisualInstructionBanner, routeProgress: RouteProgress)
-
Declaration
Swift
public func router(_ router: Router, didPassSpokenInstructionPoint instruction: SpokenInstruction, routeProgress: RouteProgress)
-
Declaration
Swift
public func router(_ router: Router, shouldRerouteFrom location: CLLocation) -> Bool
-
Declaration
Swift
public func router(_ router: Router, shouldDiscard location: CLLocation) -> Bool
-
Declaration
-
-
Declaration
-
Declaration
Swift
public func routerShouldDisableBatteryMonitoring(_ router: Router) -> Bool
-
Declaration
Swift
public func router(_ router: Router, didUpdateAlternatives updatedAlternatives: [AlternativeRoute], removedAlternatives: [AlternativeRoute])
-
Declaration
Swift
public func router(_ router: Router, didFailToUpdateAlternatives error: AlternativeRouteError)
-
Declaration
-
Declaration
-
Declaration
Swift
public func router(_ router: Router, didTakeAlternativeRouteAt location: CLLocation?)
-
Declaration
Swift
public func router(_ router: Router, didFailToTakeAlternativeRouteAt location: CLLocation?)
-
Declaration
Swift
public var routeProgress: RouteProgress { get }
-
Declaration
Swift
public var desiredAccuracy: CLLocationAccuracy { get }
-
Declaration
Swift
public var locationManagerType: NavigationLocationManager.Type { get }
-
Declaration
Swift
public func replyLocationManager(_ manager: ReplayLocationManager, published event: HistoryEvent)