Ios 映射框缓存不工作
我正在尝试在MapBox中缓存地图。当应用程序在线时,一切正常。正在正确调用tileCacheDidFinishBackgroundCache 然后,我离线重新启动应用程序。RMMapView只显示白色,而不是贴图 我的代码:Ios 映射框缓存不工作,ios,objective-c,mapbox,Ios,Objective C,Mapbox,我正在尝试在MapBox中缓存地图。当应用程序在线时,一切正常。正在正确调用tileCacheDidFinishBackgroundCache 然后,我离线重新启动应用程序。RMMapView只显示白色,而不是贴图 我的代码: - (void)viewDidLoad { [super viewDidLoad]; [[RMConfiguration sharedInstance] setAccessToken:@"pk......"]; RMTileCache * ti
- (void)viewDidLoad
{
[super viewDidLoad];
[[RMConfiguration sharedInstance] setAccessToken:@"pk......"];
RMTileCache * tileCache = [[RMTileCache alloc] initWithExpiryPeriod:0];
[tileCache setBackgroundCacheDelegate:self];
tileSource = [[RMMapboxSource alloc] initWithMapID:@"mirap.ld8dbe2c"];
mapView = [[RMMapView alloc] initWithFrame:viewMapView.bounds
andTilesource:tileSource];
[mapView.tileSource setCacheable:YES];
[viewMapView addSubview:mapView];
}
-(void)viewDidAppear:(BOOL)animated {
RMSphericalTrapezium rect = [mapView latitudeLongitudeBoundingBox];
mapView.tileCache.backgroundCacheDelegate = self;
[mapView.tileCache beginBackgroundCacheForTileSource:mapView.tileSource
southWest:rect.southWest
northEast:rect.northEast
minZoom:10.0
maxZoom:20.0];
}
- (void)tileCacheDidFinishBackgroundCache:(RMTileCache *)tileCache {
NSLog(@"DONE!");
}
以下是您需要的:
简而言之,使用映射ID初始化磁贴源是请求远程元数据URL的简称
此方法需要网络连接才能下载用于定义磁贴源的TileJSON
相反,您还希望缓存tileSource.tileJSON
,并在脱机时使用它初始化tile源
用于在脱机时本地保存以用于实例化磁贴源
顺便说一句,在同一个项目中,我使用Realm.io。这会引起冲突吗?这对我不起作用。缓存tileJson字符串后,我尝试打开一个映射,如下所示:mapSource=[[RMMapboxSource alloc]initWithTileJSON:MapTiles];和预取:[self.mapboxView.tileCache beginBackgroundCacheForTileSource:self.mapboxView.tileSource西南:西南东北:东北最小缩放:最小缩放maxZoom:maxZoom];