RoutePrefetcher (API Reference)
Class RoutePrefetcher
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.
-
Constructor Summary
ConstructorsConstructorDescriptionRoutePrefetcher(SDKNativeEngine sdkEngine) Creates a RoutePrefetcher instance for a givenSDKNativeEngine. -
Method Summary
Modifier and TypeMethodDescriptionintGets the length of the corridor along the route in front of the car which will be used to prefetch data.voidprefetchAroundLocationWithRadius(GeoCoordinates currentLocation, Double radiusInMeters) Deprecated.Will be removed in v4.27.0.voidprefetchAroundRouteOnIntervals(NavigatorInterface navigator) Prefetches map data within a corridor along the route, that is currently set for the providedNavigatorInterfaceinstance.prefetchGeoCorridor(GeoCorridor corridor, PrefetchStatusListener callback) Prefetch tiles for a given geo-corridor.voidsetPrefetchCorridorLengthMeters(int value) Sets the length of the corridor along the route in front of the car which will be used to prefetch data.voidStops listeningNavigatorInterfacepassed toprefetchAroundRouteOnIntervals(com.here.sdk.navigation.NavigatorInterface)for route progress events and stops prefetching data along the current route.
-
Constructor Details
-
RoutePrefetcher
Creates a RoutePrefetcher instance for a given
SDKNativeEngine.- Parameters:
sdkEngine-Instance of an existing SDKEngine.
-
-
Method Details
-
prefetchAroundLocationWithRadius
@Deprecated public void prefetchAroundLocationWithRadius(@NonNull GeoCoordinates currentLocation, @Nullable Double radiusInMeters) Deprecated.Will be removed in v4.27.0. Please use
PolygonPrefetcher.prefetch(com.here.sdk.core.GeoPolygon, com.here.sdk.prefetcher.PrefetchStatusListener)instead.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
nullis 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.- Parameters:
currentLocation-The center of the circle to prefetch data within.
radiusInMeters-The radius of the circle to prefetch data within.
-
stopPrefetchAroundRoute
public void stopPrefetchAroundRoute()Stops listening
NavigatorInterfacepassed toprefetchAroundRouteOnIntervals(com.here.sdk.navigation.NavigatorInterface)for route progress events and stops prefetching data along the current route. -
prefetchGeoCorridor
@NonNull public TaskHandle prefetchGeoCorridor(@NonNull GeoCorridor corridor, @NonNull PrefetchStatusListener callback) Prefetch tiles for a given geo-corridor. A geo-corridor can easily be created from a route with
Route.getGeometry()so 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.NOT_ENOUGH_SPACEis 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.- Parameters:
corridor-indicates
GeoCorridorthat can be constructed from the route.callback-is invoked to report progress and the result of prefetch. After operation is finished,
PrefetchStatusListener.onComplete(com.here.sdk.maploader.MapLoaderError)is invoked on the main thread. Progress is reported by invocation ofPrefetchStatusListener.onProgress(int)on the main thread.- Returns:
Handle that will be used to manipulate the execution of the task.
-
getPrefetchCorridorLengthMeters
public int getPrefetchCorridorLengthMeters()Gets 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.
- Returns:
The length of the corridor along the route in front of the car which will be used to prefetch data.
-
setPrefetchCorridorLengthMeters
public void setPrefetchCorridorLengthMeters(int value) Sets 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.
- Parameters:
value-The length of the corridor along the route in front of the car which will be used to prefetch data.
-