Caching and Offline Android Maps
0 Comments Published by boris March 4th, 2014 in android, technologyFollowing up on how to use custom Stamen Maps on Android – here’s a bit about how to package these map tiles with an APK so that users see a map immediately upon opening your android app. I also include caching of the map so that any new tiles downloaded are cached for future re-use.
- The first step is grabbing the map tiles you’d like. This is a good post on how to do just that with Mobile Atlas Creator. I’m attaching the .xml configuration file I used for my custom map source (Stamen Watercolor Maps)
- In Mobile Atlas Creator select the coordinates for the area in question and download the tiles. A typical city-sized map with zoom levels 0-13 might end up being around 2 MB. These are the tiles you’ll package along with your APK so you want to be conscious of file size.
- Now that you have the tiles locally, you can integrate a custom tile provider into your code. As a full example, I’m including the full demo project as a zip. (built on top of hello map)
- As a bonus, add map tile caching to your app so that any new tiles downloaded are also cached for re-use.