cachingmkmapviewofflinemktileoverlay

Caching MKTileOverlay for offline use


I've got a MKMapView that loads a map from the following server with this format:

NSString *urlTemplate = @"http://opencache.statkart.no/gatekeeper/gk/gk.open_gmaps?layers=topo2&zoom={z}&x={x}&y={y}";

And to cache the tiles loaded from this server, I know I have to save the tiles in the Documents folder of the app, but how?

And to render these tiles if present in Documents folder I know I have to subclass MKTileOverlay and make it check local storage before pulling from the server - but, again, how?

Any help would be greatly appreciated.

All the best - Chris


Solution

  • Look at MKTileOverlay's loadTileAtPath function, which allows you to load tiles from anywhere you want. You could implement a read through there.