My favorites | Sign in
Project Home Downloads Wiki Issues Source
Getting started info for mobile map rendering on Android
Updated May 3, 2014 by

These explanations are for the 0.3.x code that is now deprecated

Getting Started with mobile map rendering on Android

This article describes how to use mapsforge-map rendering on your Android device.

If you have any questions or problems, don't hesitate to ask our public mapsforge-dev mailing list for help. You can also report bugs and improvement requests via our issue tracker.

Download the free map application

The easiest way to try out or map rendering is to install the free "AdvancedMapViewer" application which can be found in our download section. In addition to that you need at least one map file on your Android device. The demo application has an integrated file picker to select and change the map file, therefore map files can be stored in any folder.

Developers can browse our Git repository at /Applications/Android/AdvancedMapViewer to check out the latest version of the program. Like everything else in the mapsforge project, the program is distributed under the LGPL3 license.

Use the map library in your application

The following HelloMapView example demonstrates, how to write a simple map application for Android. It only requires the mapsforge-map library, which is distributed under the LGPL3 license and can be downloaded in our download section. When executed, the program will render a map on the display, that can be moved and zoomed via touchscreen, zoom buttons and multi-touch gestures.

import android.os.Bundle;

public class HelloMapView extends MapActivity {
    protected void onCreate(Bundle savedInstanceState) {
        MapView mapView = new MapView(this);
        mapView.setMapFile(new File("/sdcard/path/to/"));

For those developers, who have already worked with the Google APIs Add-On, here are the differences to Google's Hello MapView example:

  1. The import paths change from to
  2. No "<uses-library ..." reference is required in the AndroidManifest.xml file.
  3. As no registration is needed for the mapsforge-map library, the MapView doesn't have a parameter for an API key.
  4. No abstract isRouteDisplayed method needs to be overridden.
  5. The MapView needs a local file that contains the map data, therefore the setMapFile(File) method is called.

The map library requires only one permission for writing cached images to the external storage (typically the phones SD card). Add the following line to your applications AndroidManifest.xml file:

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

The mapsforge-map library has a simple but powerful API, which aims to be compatible with the Google APIs Add-On. You can find the link to the latest Javadoc reference at the homepage of our project. New features will be added in the future, the performance will be improved and bugs will be eliminated, so be sure to always use the latest version of the library.

Sample applications for developers

To provide developers with various code examples, we have created an Eclipse project which contains several example programs. Each example shows a certain feature or special use case with only a few lines of code, which should be easy to understand.

You can find the latest version of this demo project in our Git repository at /Applications/Android/Samples. As new features are being implemented in the mapsforge-map library, more example applications will be added to this project in the future. Like everything else in the mapsforge project, these programs are distributed under the LGPL3 license.

Powered by Google Project Hosting