Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6649403
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:46:12+00:00 2026-05-26T00:46:12+00:00

What I want is to display a simple offline map using OpenStreetMap. I cannot

  • 0

What I want is to display a simple offline map using OpenStreetMap. I cannot find in the web the right tools to create map tiles and use it to display a map in Android. I have downloaded different resources but it seems that I don’t have any idea where to start. I want to integrate images from OpenStreetMap using JOSM but i don’t know if I can use it on Android.

Can I use Mapnik? Your help will a great thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T00:46:12+00:00Added an answer on May 26, 2026 at 12:46 am

    I’m currently developing (my first) Android application using the OpenStreetMap (OSM) API, so while I can’t help you with the JSOM, I can try to help with the OSM part:

    Assuming that you want to create a new activity in your android application that simply displays a OSM map, you might start with something like this:

    package example.stackoverflow.osmdroid;
    
    import android.app.Activity;
    import android.os.Bundle;
    
    import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
    import org.osmdroid.util.GeoPoint;
    import org.osmdroid.views.MapView;
    
    public class YourMap extends Activity {
        // The MapView variable:
        private MapView m_mapView;
    
        // Default map zoom level:
        private int MAP_DEFAULT_ZOOM = 15;
    
        // Default map Latitude:
        private double MAP_DEFAULT_LATITUDE = 38.535350;
    
        // Default map Longitude:
        private double MAP_DEFAULT_LONGITUDE = -121.753807;
    
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    
            // Specify the XML layout to use:
            setContentView(R.layout.osm_map);
    
            // Find the MapView controller in that layout:
            m_mapView = (MapView) findViewById(R.id.mapview);
    
            // Setup the mapView controller:
            m_mapView.setBuiltInZoomControls(true);
            m_mapView.setMultiTouchControls(true);
            m_mapView.setClickable(true);
            m_mapView.setUseDataConnection(false);
            m_mapView.getController().setZoom(MAP_DEFAULT_ZOOM);
            m_mapView.getController().setCenter(
                new GeoPoint(MAP_DEFAULT_LATITUDE, MAP_DEFAULT_LONGITUDE));
            m_mapView.setTileSource(TileSourceFactory.MAPNIK);
        } // end onCreate()
    } // end class YourMap
    

    Where your osm_map.xml layout may look something like this:

    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
    
            <org.osmdroid.views.MapView
                android:id="@+id/mapview"
                android:layout_width="match_parent" 
                android:layout_height="match_parent"
                android:enabled="true"      
                android:clickable="true"
            />  
    </RelativeLayout>
    

    As for the actual map tiles, there is a really cool program called Mobile Atlas Creator, which allows you to generate the necessary map tiles for the offline Android map implemented above.

    Once you have the application installed, and you want to create a new atlas, you’ll be asked to select your “desired altas format.” When this pops up, select “Osmdroid zip.”

    Once everything loads, select a region on the map that you would like to create tiles for, select the zoom levels you want tiles for, and hit the “Add Selection” button in the column on the left, followed by “Create Atlas.”

    Oh, and depending on the source, you may need to check the “Create/Adjust Map tiles” checkbox to force the tiles to be exported as PNGs — does anyone know if it’s possible to use JPG with OSM?

    Once the ZIP has been generated, I renamed it to “Mapnik.zip” and moved it to a newly created folder called “tiles” in my Eclipse Android project workspace. In order to get it working, I also had to open the zip file, and rename the top level folder from something like “Google Earth” (depending on the map source you used), to “Mapnik,” in order for the tile to display in my Android application.

    In order to actually load the tiles onto your phone, however, you’ll need to use the ADB tool from the terminal. In your ADB tool directory, you’ll want to run something like this (each line is a new command):

    ./adb shell rm -r /sdcard/osmdroid/
    ./adb shell mkdir /sdcard/osmdroi/
    ./adb push ~/path/to/your/mapnik.zip /sdcard/osmdroid
    

    Depending on the size of the map and the speed of the phone’s memory bus, this last step may take a several minutes to an hour to complete. Once done, your map should work — I hope!

    As I mentioned, this is the first time I’ve used the OSM API, so I’m by no means an expert on it, and I can only comment on what worked for me.

    Hope this will help you get started!

    EDIT:

    I didn’t have a chance to actually run the code that I wrote up yesterday, so I didn’t catch a few of the errors. I just created a new project in Eclipse, dumped my code in there, fixed a few things and got it up and running. All changes that I made are reflected in the code above! I forgot several of the basic import statements, and I forgot to add permissions to the manifest.xml file.

    The last few lines of my manifest.xml now look like this:

        <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.ACCESS_NETWORK_STATE" />
        <uses-permission android:name="android.permission.INTERNET" />
        <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    </manifest>
    

    And you also might want to add this to the manifest, although certainly not critical:

    <supports-screens 
        android:anyDensity="true"
        android:resizeable="false"
        android:largeScreens="true"
        android:normalScreens="true"
    />
    

    Add this right after the <uses-sdk ... /> part.

    Furthermore, be sure to import the following two JAR libraries:

    osmdroid-android-3.0.3.jar // Or whatever version you're using...
    

    and

    slf4j-android-1.5.8.jar // Or whatever the latest version is...
    

    Without this last JAR, my code kept crashing until I remembered to include it.

    Make sure to modify the default coordinates so that they point to a location that you actually have map tiles for, otherwise you’re not going to see much of anything, aside from a white canvas.

    Sorry for not running the code on my end first!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to display a simple GIF image in a VBox using GTK+ from
i want to use facebook's fb:dialog tag to display a simple pop-up form for
I'm using .NET 2.0 with standard controls. I want to display a simple list
Im developing a simple console application using java. I want to display currently running
I'm new to JQuery and want to use it to display a simple volume
I have a simple quiz application and I want display a nice timer /
i want to display some information in a listview using the GridView. i have
I want to display simple confirmation popup box if a user tries to close
I have a simple form for a login, and I want to display the
I need some simple databinding for a Spinner. I want to display 2 items

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.