Offline Map
In order to save traffic, offline maps of a certain province and city can be downloaded to the SD card of the mobile phone, and the map service can be freely used without a network connection. [Navinfo Navigation SDK for iOS] The product provides data store functionality, and the initial data store code is as follows:
Import the data store header file in the controller
#import <iNaviCore/MBDatastoreItem.h> #import <iNaviCore/MBDataUpdateTask.h>
Initialize
_dataStore = [[MBDatastore alloc] init]; _dataStore.delegate = self; [_dataStore setNeedsRefresh];
Achieve proxy method
Get the data source
- (void) datastoreRefreshed:(MBDatastore *)ds { NSArray *dataStoreItems = ds.root.subnodes; NSMutableArray *provinceItems = [NSMutableArray arrayWithCapacity:dataStoreItems.count]; NSMutableArray *cityItems = [NSMutableArray array]; NSMutableArray *cityDataStoreItems = [NSMutableArray array]; for (MBDatastoreItem*provinceItem in dataStoreItems) { CTMLObj *provinceNode = [CTMLObj nodeWithOwnID:provinceItem.itemId name:provinceItem.name level:1]; [provinceItems addObject:provinceNode]; if (provinceItem.subnodes.count) { for (MBDatastoreItem* cityItem in provinceItem.subnodes) { MLNodelObj *cityNode = [MLNodelObj nodeWithParentID:provinceItem.itemId ownID:cityItem.itemId name:cityItem.name level:2 isleaf:YES isroot:NO isExpand:NO]; [cityItems addObject:cityNode]; [cityDataStoreItems addObject:cityItem]; } } else { [cityDataStoreItems addObject:provinceItems]; } provinceNode.subNodes = cityItems; } }
Other agent callbacks
// start download (void)datastoreDownloadingDataItemBegan:(MBDatastore *)ds itemId:(NSString *)itemId; // Download progress callback (void)datastoreDownloadingDataItemProgressUpdated:(MBDatastore *)ds itemId:(NSString *)itemId withPercent:(CGFloat)percent; // Download completed (void)datastoreDownloadingDataItemCompleted:(MBDatastore *)ds itemId:(NSString *)itemId; // download failed - (void)datastoreDownloadingDataItemFailed:(MBDatastore *) ds itemId:(NSString *)itemId withErrCode:(MBDatastoreErrCode)code; // start installation (void)datastoreInstallDataItemBegan:(MBDatastore *)ds itemId:(NSString *)itemId; // Installation progress update callback (void)datastoreInstallDataItemProgressUpdated:(MBDatastore *) ds itemId:(NSString *)itemId withPercent:(CGFloat)percent; // The installation is complete (void)datastoreInstallDataItemFinished:(MBDatastore *)ds itemId:(NSString *)itemId; // installation failed - (void)datastoreInstallDataItemFailed:(MBDatastore *)ds itemId:(NSString *)itemId withErrCode:(MBDatastoreErrCode)code; // Data state change - (void)dataItemStateChanged:(MBDatastore *)ds itemId:(NSString *)itemId;
For specific implementation, please refer to MBDataStoreController in SDKDemo.