0

I'm using offline caching to download a preconfigured map from MapBox using:

tileCache = [[RMTileCache alloc] initWithExpiryPeriod:NSIntegerMax];
RMMapboxSource * tileSource = [[RMMapboxSource alloc] initWithMapID:mapID];
[tileCache beginBackgroundCacheForTileSource:tileSource southWest:southWest northEast:northEasth minZoom:minZoom maxZoom:maxZoom];

This all works fine and the result is a RMDatabaseCache object in the tileCache's tileCaches array.

My question is, how do I clean this specific cache up? I will have multiple of these caches, all with different map IDs and want to be able to clean up specific ones. Can't find a method that takes the mapID as a cleanup-key.

(my purpose is to have multiple offline maps, hence this approach)

Yasper
  • 501
  • 5
  • 23

2 Answers2

0

There isn't an API for this, but have a look at -[RMTileCache removeAllCachedImagesForCacheKey:] and the source of the tile source(s) in question to see how they construct the cacheKey in order to do this.

incanus
  • 5,100
  • 1
  • 13
  • 20
  • Hey, I went that route yesterday but could not find out what key was being used to store the tiles in the above situation. It wasn't the map ID and the API is a bit boxed off for this. I'll try and switch to the sourcecode-version of MapBox instead of the static library, maybe that yields some result. – Yasper Feb 25 '14 at 09:50
0

Thought I'd share the solution that worked out for me. It's a bit of a workaround but gets the job done without jumping into the MapBox sourcecode and changing it internally:

RMMapboxSource * tileSource = [[RMMapboxSource alloc] initWithMapID:MAP_ID];
RMMapView *mapView = [[RMMapView alloc] initWithFrame:CGRectZero andTilesource:tileSource];
[mapView removeAllCachedImages];

Seems simple enough.

I did have to modify the sourcecode at one point though, the database footprint didn't get smaller, so I had to jump into the MapBox code and change a line in the purseTiles:method in RMDatabaseCache as follows:

     [db executeUpdate:@"VACUUM"];
Yasper
  • 501
  • 5
  • 23