How to implement a simple OpenStreetMap on Android

OpenStreetMap (OSM) is a free editable Wikipedia like world map. More information at Wikipekia OSM

OSM allows user to download maps for offline use, this is a big advantage over Google Map, which is internet based the map. With OSM a map can be per download to an application, and can be used without internet.

Implement a Simple Open Street Map

Create an Android project.

In res/layout/activity_main.xml add:


In AndroidManifest.xml add flowing permissions:

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

To use OSM in android app, there are two jars need to be included, osmdroid-android-x.xx.jar and slf4j-android-1.5.8.jar. osmdroid is a set of tools for OpenStreetMap data; SLF4J is a simplified logging facade.

  1. osmdroid


  2. SLF4J Android


Import jars to project library, and the simple OSM is implemented.

Simple functions

Add some simple functions to the map:

private MapView mapView;
private MapController mapController;

protected void onCreate(Bundle savedInstanceState) {
    mapView = (MapView) this.findViewById(;
    mapController =(MapController) this.mapView.getController();

This will give touch controls: move location, zoom (like a simple Google map). Here is a screenshot:

simple osm

To implement a simple OSM, remember download jars to project library, give permissions in Android manifest file and set view in layout file, then you can add more functions in the map Activity.

Source code: on GitHub

comments powered by Disqus