Download Routing Data and Map Tiles

This guide explains how to download routing data and map tiles for a selected region so the iOS app can calculate routes and display maps without network access.

Use the following script:

1
func download(regionId: Int64) async throws {
2
let result = try await NBNavigation.downloadRegion(
3
regionId: regionId,
4
onProgress: { routingProgress in
5
// Optional routing-data progress callback.
6
}
7
)
8
print("routing status=\(result.downloadStatus.rawValue)")
9
}

downloadRegion starts the routing-data and map-tile downloads concurrently and returns the routing download result. If either task throws an error, the combined call throws and cancels the other task if it is still running. Data already written is not rolled back, and the download can be resumed later.

The combined download is not transactional. After a failure, read the unified progress and installed state again to determine the actual result for each dataset. To download only routing data or only map data, use downloadOfflineRoutingRegion or downloadOfflineMapRegion respectively.