RoutePrefetcher
public class RoutePrefetcher
extension RoutePrefetcher: NativeBase
extension RoutePrefetcher: Hashable
Supports downloading of map data - in advance - into the cache to optimize temporary offline use cases that rely on cached map data. This allows scenarios such as navigation to work in a specific area reliably even though the network might be offline at that time. Please note, this class puts data in the map cache, which has its own size constraints, and extensive usage may start evicting old cached data. Note: This is a beta release of this feature, so there could be a few bugs and unexpected behaviors. Related APIs may change for new releases without a deprecation process.
-
Creates a RoutePrefetcher instance for a given
SDKNativeEngine.Declaration
Swift
public init(_ sdkEngine: SDKNativeEngine)Parameters
sdkEngineInstance of an existing SDKEngine.
-
The length of the corridor along the route in front of the car which will be used to prefetch data. Upper limit for length is 50000 meters, when the requested length is greater than upper limit, then 50000 meters set. Lower limit for length is 1000 meters, when the requested length is less than lower limit, then 1000 meters set. The route corridor has a default length of 10 km and a width of 5 km.
Declaration
Swift
public var prefetchCorridorLengthMeters: Int32 { get set } -
Prefetches map data within a user-defined circular area around a given location. The radius, specified in meters, must be between 1 km and 50 km. If
nilis passed as the radius, a default value of 2 km is used. It is recommended to call this method once before starting navigation to ensure a smooth experience.To control list of map content features for area prefetch, use
LayerConfiguration.enabledFeatures.Declaration
Swift
@available(*, deprecated, message: "Will be removed in v4.27.0. Please use `PolygonPrefetcher.prefetch(...﹚` instead.") public func prefetchAroundLocationWithRadius(currentLocation: GeoCoordinates, radiusInMeters: Double?)Parameters
currentLocationThe center of the circle to prefetch data within.
radiusInMetersThe radius of the circle to prefetch data within.
-
Prefetches map data within a corridor along the route, that is currently set for the provided
NavigatorProtocolinstance. If no route is set, no data will be prefetched. The route corridor defaults to a length of 10 km and a width of 5 km. To prefetch the whole route before navigation has been started seeRoutePrefetcher.prefetchGeoCorridor(...). Map data is prefetched only in discrete intervals. Prefetching starts 1 km before reaching the end of the current corridor. Prefetching happens based on the current map-matched location - as indicated by theRouteProgressevent. This method should be called right after navigation has started. In case of default prefetch length first prefetching will start after traveling a distance of 9 km along the route.To control list of map content features for prefetch, use
LayerConfiguration.enabledFeatures.Declaration
Swift
public func prefetchAroundRouteOnIntervals(navigator: NavigatorProtocol)Parameters
navigatorThe
NavigatorProtocolto listen for Route Progress to prefetch data ahead. -
Stops listening
NavigatorProtocolpassed toRoutePrefetcher.prefetchAroundRouteOnIntervals(...)for route progress events and stops prefetching data along the current route.Declaration
Swift
public func stopPrefetchAroundRoute() -
Prefetch tiles for a given geo-corridor. A geo-corridor can easily be created from a route with
Route.geometryso navigation on this route is possible in offline cases. Please note, tiles will be saved in mutable cache so when there is not enough space to accommodate new prefetched tilesMapLoaderError.notEnoughSpaceis returned. When updating mutable cache, all tiles will be unusable. Please re-download the geoCorridor again. Please also note, any route calculation may not possible on prefetched tiles.To control list of map content features for corridor prefetch, use
LayerConfiguration.enabledFeatures.Declaration
Swift
public func prefetchGeoCorridor(corridor: GeoCorridor, callback: PrefetchStatusListener) -> TaskHandleParameters
corridorindicates
GeoCorridorthat can be constructed from the route.callbackis invoked to report progress and the result of prefetch. After operation is finished,
onComplete(...)is invoked on the main thread. Progress is reported by invocation ofonProgress(...)on the main thread.Return Value
Handle that will be used to manipulate the execution of the task.