ios 应用中的 Mapbox 缓存
Mapbox caching in ios app
在应用程序中我有一些mapViews
,我想支持离线模式(缓存)。所以:用户安装的应用程序,主屏幕包含 mapView
并且应该缓存它。然后用户关闭 Wi-Fi 和 3G,并尝试查看另一个 mapView
(另一个 viewController
)。现在还没有下载。但是主屏幕的地图没问题。我缓存的方式不对吗?
配置地图的代码同上:
[[RMConfiguration sharedInstance] setAccessToken:@"pk.***"];
RMMapboxSource *tileSource = [[RMMapboxSource alloc] initWithMapID:kMapboxMapID];
[tileSource setCacheable:YES];
[self.mapView.tileCache setBackgroundCacheDelegate:self];
[self.mapView.tileCache beginBackgroundCacheForTileSource:tileSource southWest:CLLocationCoordinate2DMake(55.767363, 37.592843) northEast:CLLocationCoordinate2DMake(55.799801, 37.671229) minZoom:11 maxZoom:11];
self.mapView = [[RMMapView alloc] initWithFrame:self.view.bounds andTilesource:tileSource];
self.mapView.delegate=self;
[self.view addSubview:self.mapView];
如果您不使用 RMTileCache
的下载方法来预取地图区域,则仅当试图在第二个视图控制器中查看的地图区域相同时才有效正如在第一个中已经看到的那样。
在应用程序中我有一些mapViews
,我想支持离线模式(缓存)。所以:用户安装的应用程序,主屏幕包含 mapView
并且应该缓存它。然后用户关闭 Wi-Fi 和 3G,并尝试查看另一个 mapView
(另一个 viewController
)。现在还没有下载。但是主屏幕的地图没问题。我缓存的方式不对吗?
配置地图的代码同上:
[[RMConfiguration sharedInstance] setAccessToken:@"pk.***"];
RMMapboxSource *tileSource = [[RMMapboxSource alloc] initWithMapID:kMapboxMapID];
[tileSource setCacheable:YES];
[self.mapView.tileCache setBackgroundCacheDelegate:self];
[self.mapView.tileCache beginBackgroundCacheForTileSource:tileSource southWest:CLLocationCoordinate2DMake(55.767363, 37.592843) northEast:CLLocationCoordinate2DMake(55.799801, 37.671229) minZoom:11 maxZoom:11];
self.mapView = [[RMMapView alloc] initWithFrame:self.view.bounds andTilesource:tileSource];
self.mapView.delegate=self;
[self.view addSubview:self.mapView];
如果您不使用 RMTileCache
的下载方法来预取地图区域,则仅当试图在第二个视图控制器中查看的地图区域相同时才有效正如在第一个中已经看到的那样。