Android OpenStreetMap Offline Map Setup
OSM Android Offline Map Setup

Hello guys, last month I had to do some research on Android Offline Map usage for my freelance project. I can say map usage is kind a annoying for developers and there are rare documentations about offline map setup. So I decided to publish a offline map library.

After my research I decided to use OSM. In this article I will explain how to download map-tiles and how to use them on any Android app with using OSM and MOBAC.

Lets start!

If you want to use an offline map in your application, the user must download the tile set before using the map. And ready to go tile sets are really large files. If you still want to use ready to go map tiles, you can visit openmaptiles.com.

What should we do, If we do not want to force user to download map tiles ?

First we need to download MOBAC (Mobile Atlas Creator) from here.

(Mobile Atlas Creator) from here. Open MOBAC by clicking start shell script and select Osmdroid SQLite and click OK

Usage of MOBAC is really simple. You can choose any map source from left panel. Select map source (selecting osm is better) and zoom-levels (15–14–13–12 are ideal) as you desire. If you choose all zoom levels, your download size will inrease. I do not recomend it. As you know Google warns you about your application size :)

Next step is selecting a map area. In this picture I selected part of Istanbul for my usage. You can roam on map source with right click. Select your area and press ‘Add selection’ button from left panel.

After selecting desired area, press ‘Create Atlas’. You download will start. I recomend you to check ‘Ignore download error and continue automatically’.

When your download is finished your SQLite map tiles will be ready under Mobile Atlas Creator 2.1.2\atlases folder. You just need to remane it to map.sqlite and that is all. Our offline map source is ready to use :) Lets jump to next step.

Now we can create our Android application. After creating our app, we need to copy our map.sqlite into assets folder.

You will probably ask me to why we are copying sqlite file under assets folder, right ? Let me explain. If you use OSM and there is no internet connection, OSM starts to search any offline data understorage/emulated/osmdroid/tiles direction. Our code will transfer this SQLite file into this direction. This is also explains why program asks storage permissions at first opening :)

We need to add AndroidOfflineMap dependicies into gradle.

And the simple usage is;

Lets run the application.

C’est ça!

Our offline map is ready to use !

You can go to github page from here.

Thanks for reading. If you have any further questions just ask :)
['Egemen Özogul']
['Android App Development', 'Offline Maps', 'Maps', 'Openstreetmap', 'Android']