Map data prefetching (v.2.1.x - iOS)
When using the online SDK, it is possible to prefetch map data for offline use. The prefetching process downloads the required tiles and stores them in a local database.
There are three data types that can be prefetched (NMPrefetchedMapDataType):
Map_Drawing– drawing map data, which is used to display the map;Map_Routing– routing map data, which is used for offline route calculation;Poi– POI data, used to display points of interest on the map.
To prefetch the data, use one of the two methods of the NMMapDataPrefetchManager:
prefetchData:forArea:listener:– to prefetch the data for specific area;prefetchData:forRoute:listener:– to prefetch the data along a route.
Each of these methods accepts the data type to prefetch and an instance of a class implementing the NMMapDataPrefetchListener interface, which can be used to receive notifications about data download progress. The methods return an NMMapDataPrefetchSession object that provides the cancel method for cancelling the download.
Example:
NMMapDataPrefetchSession *session;
...
NMMapRectangle *area = [[NMMapRectangle alloc] initWithTopLeft:topLeft
bottomRight:bottomRight];
session = [pathwayProSDK.mapDataPrefetchManager prefetchData:Map_Drawing
forArea:[[NMMapRectangle alloc] initWithTopLeft:topLeft
bottomRight:bottomRight]
listener:self];
...
- (void)onProgressUpdatedWithNumberOfFetchedTiles:(NSInteger)numberOfFetchedTiles
totalNumberOfTiles:(NSInteger)totalNumberOfTiles {
NSLog(@"onProgressUpdatedWithNumberOfFetchedTiles: %ld totalNumberOfTiles: %ld", (long)numberOfFetchedTiles, (long)totalNumberOfTiles);
}
- (void)onSucceededWithTotalNumberOfTiles:(NSInteger)totalNumberOfTiles {
NSLog(@"onSucceededWithTotalNumberOfTiles: %ld", (long)totalNumberOfTiles);
}
- (void)onFailedWithError:(nullable NSError *)error {
NSLog(@"onFailedWithError: %@", error == nil ? @"<no description>" : error.localizedDescription);
}