MapboxNavigationService
public class MapboxNavigationService : NSObject, NavigationService
extension MapboxNavigationService: CLLocationManagerDelegate
extension MapboxNavigationService: RouterDelegate
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 }
-
Declaration
Swift
public func start()
-
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(routeResponse:routeIndex:routeOptions:routingProvider:credentials:locationSource:eventsManagerType:simulating:routerType:﹚") 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
required public 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 route.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.
-
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 }
-
RoutingProvider
, used to create route.Declaration
Swift
public var routingProvider: RoutingProvider
-
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.
-
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 router(_ router: Router, willRerouteFrom location: CLLocation)
-
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 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 var locationManagerType: NavigationLocationManager.Type { get }