This project has moved and is read-only. For the latest updates, please go here.

How to cache Tiles Universal App

Feb 20, 2015 at 9:32 AM

First of all thanks for this awesome library. However, I'm having troubles figuring out how to cache the Tiles in a Universal App (or at least Windows Phone 8.1). I have two TileLayers of which I want to cache one. Could someone point me in the right direction or perhaps post some sample code on how to implement this?

Thanks a lot!
Feb 20, 2015 at 10:57 AM
Edited Feb 20, 2015 at 11:02 AM
If you take a look at the MainPage.xaml.cs file in the sample StoreApplication, you'll see the commented lines
//TileImageLoader.Cache = new MapControl.Caching.ImageFileCache();
//TileImageLoader.Cache = new MapControl.Caching.FileDbCache();
Put one of these into your application code, and add the appropriate assembly reference to either ImageFileCache.WinRT or FileDbCache.WinRT. I consider both libraries to be kind of experimental (i.e. not well tested), so take them with some precaution. That is also the reason why they are not part of the NuGet package, and you'll have to take them from the project sources downloaded from here.

As soon as the static TileImageLoader.Cache is set, you can control which TileLayers are cached by setting their SourceName property. If a TileLayer has a SourceName, it will be cached, otherwise it won't.

The default location for cached map tiles is ApplicationData.Current.TemporaryFolder, because this folder is automatically cleaned up be the operationg system. Be careful when you choose a different cache location, as cached files may then never be deleted.
Marked as answer by SolveSoul on 2/20/2015 at 4:11 AM
Feb 20, 2015 at 12:13 PM
Thanks, I got it implemented. I do want to mention I used the FileDbCache assembly since the ImageFileCache caused the map to be white. I wanted just wanted to let you know.

Thanks a ton!