In part 2 of my tutorial (here is part 1) I’ll show you how to create offline maps using Mobile Atlas Creator and how to define min and max-zoom-levels in your app.
Mobile Atlas Creator is a cool open-source project, that allows you to use different map providers (OpenStreetMap, Google Maps, Bing Maps, Yahoo Maps, …), donwload these maps and export to different atlas formats. Have a look at their website (http://mobac.dnsalias.org/) and download the latest stable version.
Just unzip, start the .jar-file and you will be presented a world map.
On the left side you can choose which map provider to use, i.e. OpenStreet Mapnik, Yahoo, …
Choose OpenStret Mapnik for now.
Now navigate and zoom in to your preferred area, I took Hamburg, Germany using the arrow keys on your keyboard and the zoom selector in the upper left corner of the map.
Now make a selection of the parts you want to have as an offline map.
In the left panel you may now select which zoom levels to include in your offline map. Just select the numbers you want where 18 is highest detail level and 0 is lowest. The higher detail you want, the more tiles you have to download, the higher the final size of the offline map will be.

When you’re happy with your selection on the map, click “Add Selection” in the “Atlas Content” area, and for “Atlas settings” select Osmdroid ZIP.

Now start atlas creation by clicking on the “Create Atlas” button. Now the selected parts of the map will be downloaded and bundled into a Osmdroid ZIP map. After some time, depending on your internet connection and the number of tiles you want to download, creation of the offline map is ready. You can now close Mobile Atlas Creator and have a look at the Mobile Atlas Creator folder. You’ll now find a subfolder “atlases” and inside the subfolder a .zip-file containing all the map tiles (you can confirm that by unzipping the file).
Now let’s use this map in our app. Open the app we created in the last part.
We want to make sure we’re not using any data connection to download the map tiles, so just set
mapView.setUseDataConnection(false)
somewhere after the mapView instantiation and before setContentView(mapView).
Let’s also delete the map cache in case you followed the last tutorial. You can find a folder “osmdroid” on your android’s sdcard, just delete everything in that folder and instead put the zip-file we created inside.
Now adjust the zoom level and the latitude/longitude in your app to point to a place in the map you created and start your app.
You should now see a map, but that map wasn’t downloaded on-the-fly, now it’s using the map tiles in the zipped-atlas you created! You can confirm that by moving outside of the area you zipped and you will just see grey map tiles.
Problem is: you still can zoom out of the zoom levels you downloaded or zoom closer than you wanted the user to (you provided no maps for that zoom level). That’s ugly because the user only sees grey maps and may get lost.
Let’s discuss how to solve that problem in the next part of the tutorial.

16. Mai 2011 um 2:01 am
Thanks for these tutorials – they are very straightforward and helpful! Unfortunately I cannot seem to get my maps to successfully use the ZIP file created in the Mobile Atlas Creator. I have copied the zip into the same spot on the SD card where I found the cached pngs from the first tutorial (the “osmdroid” folder) but as soon as I set the map to not use a data connection I just get gray squares. Of course I have checked and double checked that I am looking at the same part of the map in the app that I created the tiles for…
Do you know of any way to inspect errors from osmdroid or otherwise figure out why it is not loading the zip file?
Thanks!
16. Mai 2011 um 2:07 am
Hi Zane, thanks for the compliments. I haven’t had the problem you describe, but I will have a look again at my code.
16. Mai 2011 um 2:33 am
Ah, so I solved my problem. For whatever reason my version of osmdroid uses map tiles in the .png.tile extension, but the “Osmdroid Zip” option in Mobile Atlas Creator creates plain .png files. I fixed it by using the “OSMAND” tile storage format in Mobile Atlas Creator instead.
18. Mai 2011 um 1:33 pm
Thank you Zane, both of your tutorials helped a bunch.
rick
8. Juli 2011 um 4:05 am
Hi,
Great tutorial, but I’m facing an issue that mine device don’t have an sd card.
Can I still use map in offline mode? Could You please give me a tip how to redirect it to a different storage than sd card to read map from ?
Thanks in advance.
8. Juli 2011 um 12:35 pm
Hi!
Well you could download the zip-File on first start of the activity to the internal storage/cache folder, but I don’t yet know how to change the default path to internal storage.
If you find a method to do this let me know.
11. Juli 2011 um 12:22 am
Since I didn’t find a way how to change it (there is no parameter or something), I’ve checked out source code, attached it to my solution (you Can follow this HOW TO: http://code.google.com/p/osmdroid/wiki/HowToUse). Then you need to write your own implementation of MapTileProviderBase, especially getMapTile() method. You can take a look on MapTileProviderBasic class as an example. This class (MapTileProviderBasic) is being used by default and you have to replace it.
10. Oktober 2011 um 9:25 am
hi! Thank you for your tutorial. I am waiting for your next tutorial on zoom in/out. I really need your tutorial on it because I cannot proceed without it. Please use the example OSM Mapnik. Thank you..