Route Requests

Send all route requests through NBNavigation.fetchRoute. The method uses the current RoutingConfig to control online, offline and hybrid routing behavior. RouteFetchResult.source can be used to report the actual source at any time.

Request a route through NBNavigation:

1
let options = NavigationRouteOptions(
2
waypoints: waypoints,
3
profile: NBNavigationMode.car
4
)
5
6
let result = try await NBNavigation.fetchRoute(options: options)
7
let routes = result.routes
8
print("route source=\(result.source)")
9
10
// Pass routes to the existing Default UI or custom navigation flow.

To override the strategy for one request, call fetchRoute(options:routingConfig:). This does not modify the process-wide configuration. Callback-based integrations can use:

1
NBNavigation.fetchRoute(options:completion:)

Or

1
NBNavigation.fetchRoute(options:completionHandler:).
RouteModeBehavior
onlineOnlyUses online routing only. The request fails if the network is unavailable or the online request fails. No offline fallback is attempted.
offlineOnlyUses offline routing only. The offline engine must be initialized and required routing data must be available. No online fallback is attempted.
onlinePreferredUses online routing first when the network is reachable. If the online request fails or times out, offline routing is attempted only when the offline engine was ready when the request started. If online routing is unavailable but offline routing is ready, the request starts directly with offline routing.
offlinePreferredUses offline routing first when the offline engine is ready. If the offline request fails or times out, online routing is attempted only when the network was reachable when the request started. If offline routing is unavailable but online routing is reachable, the request starts directly with online routing.
smartSelects from the sources available when the request starts. When both sources are available, it tries online routing first and then offline routing. When only one source is available, it uses that source. The request fails when neither source is available.

offlineOnly succeeds only after the offline engine is initialized and routing data for the required region is downloaded. Map-tile availability does not determine whether route calculation succeeds, but it does determine whether the map displays correctly without a network connection.