我正在尝试使用Mapbox下载地图以供离线使用。但运气不好。内存使用量呈指数增长,应用程序最终崩溃。
我这样做。
RMMapboxSource *onlineSource = [[RMMapboxSource alloc] initWithMapID:kMapboxMapID];
RMMapView *mapView = [[RMMapView alloc] initWithFrame:self.view.bounds andTilesource:onlineSource];
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(37.774527, -122.420091);
mapView.zoom = 50;
mapView.maxZoom = 50;
for (id cache in mapView.tileCache.tileCaches)
{
if ([cache isKindOfClass:[RMDatabaseCache class]])
{
RMDatabaseCache *dbCache = (RMDatabaseCache *)cache;
NSLog(@"current cache size: %lld", dbCache.fileSize);
if (dbCache.fileSize < 20000)
{
[mapView.tileCache setBackgroundCacheDelegate:self];
NSInteger minZoom = tileSource.minZoom;
NSInteger maxZoom = tileSource.maxZoom; // here I am fetching all but this might be too much
[mapView.tileCache beginBackgroundCacheForTileSource:tileSource southWest:tileSource.latitudeLongitudeBoundingBox.southWest northEast:tileSource.latitudeLongitudeBoundingBox.northEast minZoom:minZoom maxZoom:maxZoom];
}
break;
}
}
但内存拍摄和应用程序崩溃。 有谁可以帮帮我?提前谢谢。