Using OSMDroid for Offline mapping in Android, step-by-step [Tutorial]

For my EnschedeLocator app, I wanted the users to be able to store an offline map on the device and see it while navigating to their destinations. In our BeerFinder project at NTNU last year, we were able to do this using Nutiteq’s android library, but poor documentation lead me to looking for other solutions. I discovered OSMDroid which is a library that aims to be an opensource alternative to Google MapView in Android.

Below, I will outline how I did it and how I solved some small obstacles i encountered. Note that there may be other and better ways of doing this, but this is what worked for me.

Tools needed

  • Eclipse with Android SDK (assuming you know the basics here).
  • Mobile Atlas Creator, for preparing map tiles.
  • OSMDroid library, available here. I used osmdroid-android-3.0.7.jar.
  • SLF4J Android library, available here. I used slf4j-android-1.5.8.jar. Without this library I got a NoClassDefFoundError when trying to run the app. Adding this library somehow fixed it [source].

Preparing the map

To download the map tiles I used Mobile Atlas Creator.

My steps were as follows, most settings are done in the options pane to the left of the map:

  1. Set atlas format to Osmdroid ZIP [Atlas - Convert Atlas Format].
  2. Set your map area coordinates, either by clicking and dragging on the map, or by setting min and max coordinates in the coordinate selection pane to the left.
  3. Set map source to OpenStreetMap Mapnik. Note: I originally set my source to something else, and the map wouldn’t appear on my phone. I’m sure there’s a simple fix for this, but haven’t looked into it yet.
  4. Select the zoom levels you want to include. This will impact the storage space required. As you select more levels, the number of tiles needed are displayed. Each pane takes about 20kilobytes. I included all levels because my area of interest is so small that I’m not to concerned about that yet, I might make small versions available when I publish the app. For my area, 178 tiles + 20kB = 3.48MB.
  5. In the Atlas Content pane, set the name of your map first, then click “add selection” (the name really isn’t important, though).
  6. Then select “Create atlas” and your map is stored in the atlas folder under Mobile Atlas Creator.
  7. Move the resulting zip-file to /mnt/sdcard/osmdroid/ on your device. (For a slight improvement in performance, you can unzip the file and move the resulting Mapnik-folder to /mnt/sdcard/osmdroid/tiles/ instead. The difference in size isn’t that big, but the zip-file might be a good way to organize different maps if you have several areas, but I digress).

That’s it for preparing the map! Again, these are steps and settings that worked for me, others might work better, but I haven’t researched them yet.

Importing the libraries to Android project

When I attach external libraries to my projects I put the .jar-files in the project folder so that I know where they are.

  • Move the osmdroid-android-3.0.7.jar and slf4j-android-1.5.8.jar (and osmdroid-android-3.0.7-javadoc.jar for documentation) into your project folder.
  • In eclipse, right click the project and click refresh, the files should show up.
  • Right-click the files and select [Build Path -> Add to Build Path].
  • Then, go into [Build Path -> Configure Build Path] and under the Libraries tab select the osmdroid.jar and edit javadoc location to the osmdroid-android-3.0.7-javadoc.jar file.

The code

This example code shows the map parts of the Activity class and should be enough to view the map. Note that this Activity doesn’t need to specify an .xml layout as we’re doing it in the code.

package com.yourpackage.name;

import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;

import android.app.Activity;
import android.os.Bundle;

public class OSMDroidMapActivity extends Activity {
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);

        MapView mapView = new MapView(this, 256); //constructor
        mapView.setClickable(true);
        mapView.setBuiltInZoomControls(true);
        setContentView(mapView); //displaying the MapView
        mapView.getController().setZoom(15); //set initial zoom-level, depends on your need
        mapView.getController().setCenter(new GeoPoint(52.221, 6.893)); //This point is in Enschede, Netherlands. You should select a point in your map or get it from user's location.
        mapView.setUseDataConnection(false); //keeps the mapView from loading online tiles using network connection.
    }
}

This displays the MapView only. If you would like to add some other Views, you can remove the setContentView(mapView); and add the following to your class and remember to do the right imports.

TextView myTextView = new TextView(this);
        myTextView.setTextAppearance(this, android.R.style.TextAppearance_Large_Inverse);
        myTextView.setText("Enschede, Netherlands");
        Button myUselessButton = new Button(this);
        myUselessButton.setText("Click");

        final RelativeLayout relativeLayout = new RelativeLayout(this);
        final RelativeLayout.LayoutParams mapViewLayoutParams = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.FILL_PARENT,RelativeLayout.LayoutParams.FILL_PARENT);
        final RelativeLayout.LayoutParams textViewLayoutParams = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        final RelativeLayout.LayoutParams buttonLayoutParams = new RelativeLayout.LayoutParams(
                        RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        buttonLayoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM);

        relativeLayout.addView(mapView, mapViewLayoutParams);
        relativeLayout.addView(myTextView, textViewLayoutParams);
        relativeLayout.addView(myUselessButton,buttonLayoutParams);
        setContentView(relativeLayout);

Basically, we did three things here:

  • Create the TextView and Button.
  • Create the RelativeLayout and the rules for the different Views.
  • Add the Views to the Layout and finally set the Activity to show the layout.

Now we should get something like this:

  • Appreciate

    you have just done some of the very few good tutorials about osmdroid!
    I would like to congratulate you and keep it up!!

    • http://www.haakseth.com/ John Wika Haakseth

      Thank you very much. Hope it was helpful :-)

  • Appreciate

    Do you have any tutorials about adding points on a map or using locationlisteners to view device location with a marker on the map?

    • http://www.haakseth.com/ John Wika Haakseth

      I might make one at a later time (I’m a little busy with school these days), but for LocationListener, I will refer you to http://developer.android.com/guide/topics/location/obtaining-user-location.html. For the marker you simply add a SimpleLocationOverlay: http://code.google.com/p/osmtracker-android/source/browse/trunk/src/me/guillaumin/android/osmtracker/activity/DisplayTrackMap.java

  • Kelsie Zhao

    Thank you ! Great tutorial!
    Just one question. You mentioned “move the resulting zip file to sd card” after created manually. Is that possible to do that from code? I am building an app for some other guys, they may not want to add files manually……Please help!!

    • http://www.haakseth.com/ John Wika Haakseth

      Thank you very much, Kelsie. 

      Yes, this is possible. You bundle the zip file with your app by placing it in the assets-folder. Then have a look at the CopyAssets() and CopyFile() methods here: http://stackoverflow.com/questions/4447477/android-how-to-copy-files-in-assets-to-sdcard 

      In my application, I called the CopyAssets in the onCreate method, checking if the file already existed. A better option might be to check if the file exists already, and if not, ask the user if the app should copy it there.

      It’s probably also possible to overwrite a class in OSMDroid to let it look for the map in the assets-folder in stead of the sd-card, but I haven’t researched this. If you do, please let me know how it goes.

      John

  • mata

    hello… thank’s for your tutorial. it’s very helpful to me :) and i have one question for you :D .. is it possible to modify the map view like bird viewfrom a single point instead of viewing from above? example :
    http://blog.laptopmag.com/wpress/wp-content/uploads/2011/05/3D-Maps-cropped.png 
    thank’s for the answer :D

    • http://www.haakseth.com/ John Wika Haakseth

      Hi! I don’t think that’s implemented in OSMDroid. If you find anything on it, don’t hesitate to comment about it here :)

  • MAKSumon

    Hello… thanks for the tutorial. But in my app no map showing… Help me…

    • http://www.haakseth.com/ John Wika Haakseth

      Well, to debug that, some more information is needed. Did you perform all the steps in the tutorial?

    • MAKSumon

      Sorry… It’s working. I made the mistake while copying .zip from assets to the sdcard. Thanks a lot for the brilliant tutorial.

      • http://www.haakseth.com/ John Wika Haakseth

        Good to hear :-)  

  • Sedghi Moradi

    Hello,thank you sooooooooooooooo muh for this tutorial,it was really helpful for me
    Be successful :)

    • http://www.haakseth.com/ John Wika Haakseth

      Glad to hear it :-)  

  • Rorydunbar

    Hello, I am trying your tutorial. If I do not have an sd card where should I put the map file?

    Your help wold be greatly appreciated.

    • http://www.haakseth.com/ John Wika Haakseth

      Hi, it’s not a physical, external SD-card, but the SD-card partition on your phone. I know it’s a bit confusing :-)

      • Rorydunbar

        Yeh I’m an idiot lool. Trying to run before I can walk… I have went back and learnt the concerts i.e. overlays etc and now I am going to do this tutorial.

        Thank you very much for getting back to me!!

        Did you every create a GIT project for your app?

        • http://www.haakseth.com/ John Wika Haakseth

          No worries, it’s a strange way to name that partition, I didn’t get it right away either. I’ll put it up on github when I publish it in Play Store, just haven’t gotten around to it. 

          https://github.com/haakseth

          • Rorydunbar

            Hi John,

            I have tired to get the offline map showing and I have problems. I have followed your instructions down to a tee. I had to make minor changes to your code as I got errors when copying. Can you see did my changes have a bad effect? I would really appreciate the help. 

            I have spent far too long at this. I have added the files to /sdcard/osmdroid/. I have changes the name of the .zip and unzipped folder to Mapnik and tiles but nothing seems to work. 

            Problem is I do not see the map. I don’t get any errors just grey squares. When I zoom out I see one tile of a section of the world. Can I hardcode a path?

            Any guidance would be appreciated.

            import org.osmdroid.util.GeoPoint;
            import org.osmdroid.views.MapView;import android.app.Activity;import android.os.Bundle;
            public class map extends Activity { public void onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);    MapView mapView = new MapView(this, 256); //constructor    mapView.setClickable(true);    mapView.setBuiltInZoomControls(true);    setContentView(mapView); //displaying the MapView    mapView.getController().setZoom(15); //set initial zoom-level, depends on your need    mapView.getController().setCenter(new GeoPoint(52.221, 6.893)); //This point is in Enschede, Netherlands. You should select a point in your map or get it from user’s location.    mapView.setUseDataConnection(false); //keeps the mapView from loading online tiles using network connection.}}

          • http://www.haakseth.com/ John Wika Haakseth

            Is your GeoPoint(lat, long) correct? The one in this code is in Enschede, Netherlands, so if that is outside of your map area, it will not show. You can use Google Earth to find different values for your initial center.

          • Rorydunbar

            Sorry yes I put Ireland in 53.000, 7.000.

            I have been testing on my phone which is not good for debugging so I have pushed the map.zip to the /sdcard/osmdroid directory on the emulator and when I run on the emulator I get an error in the log cat “Error downloading MapTile”

            So it looks like its trying to connect to the internet… ??

          • Rorydunbar

            FYI, adding the internet permission fixed the error. I wiped the data in the osmdroid folder copied over the .zip file and when I run the application, a tile folder is created with only two folders and 4 .png files. Im confused.

          • http://www.haakseth.com/ John Wika Haakseth

            Good to hear you figured it out.

          • Rorydunbar

            Sorry John I didnt get it working. I tried all the above and still no joy. I read an article that said MOBAC and Mapnik are not working together at the moment so I am going to try using Mapquest tiles. Does your tutorial still work, can you run the code?

          • Rorydunbar

            FYI you have to use MapQuest tiles not Mapnik tiles when using MOBAC to download. 

            Great tutorial BTW!! Guys like you are what the internet is all about.

          • http://www.haakseth.com/ John Wika Haakseth

            Interesting, I’ll look into it when I have time (back to school).

            Thank you very much for your kind words :-)

          • Archie

            I had the same problem when trying to use my phone in Debug mode. After searching for hours here is the solution I found: http://stackoverflow.com/questions/17418408/enable-the-sd-card-while-usb-debugging

            Basically you have to Select the “Touch for other USB options” and select Connect as Camera”… the other selections lock up the SD Card so all you get is grey tiles

  • Goldy567

    Can you draw an ellipse or cycle on the map?

    • http://www.haakseth.com/ John Wika Haakseth

      This is possible, I would start exploring the OverlayItem class: http://code.google.com/p/osmdroid/source/browse/trunk/osmdroid-android/src/org/osmdroid/views/overlay/OverlayItem.java?r=632

  • Dan A.S.

    Also works with other maps if they have the same directory structure and png format for images (exported as osmdroid zip).

    / sdcard / osmdroid / theosmdroid.zip

    Inside the zip file:
    Mapnik /
          NN / (zoom levels)
              NNNN / (folder area)
                         xxxx.png (png images)
    Tested.

    • http://www.haakseth.com/ John Wika Haakseth

      Excellent! Thanks for the input :-)

  • Rayiez

    For me It works fine on android4.1 but it shows empty map on android 4.0.
    Any ideas what can be the problem?

    • http://www.haakseth.com/ John Wika Haakseth

      Not sure, pretty sure I’ve made it work with ics before (it’s what I was running while making my app). You should try running it while connected to eclipse (adb), so that you can get the debug messages.

    • http://www.haakseth.com/ John Wika Haakseth

      Also, make sure the path to the folder of the map is correct.

  • http://www.facebook.com/guillaume.lefloch2 Guillaume le Floch

    Hi, I look your project very interesting. Thanks for this tutorial!!

    I just wanted to know, I that normal that there is no onCreate() function?

    • http://www.haakseth.com/ John Wika Haakseth

      You’re very welcome, glad you liked it :-)

      This example just inherits the onCreate from Activity: http://developer.android.com/reference/android/app/Activity.html
      For more advanced applications, you may want to override it. 

  • Girish

    Hi John, Thanks for the detailed tutorial. I was searching for something like this.
    But when I tried doing the same myself, I don’t see the map images shown. Only the lines (vertical and horizontal) are displayed in white background. I have created the tiles using MOBAC and tried using both zip as well as Mapnik containing tiles to my phone /mnt/sdcard/osmdroid/ folder. Please let me know what could be wrong.
    My requirement is for an Android tile based preview alternative to CATileLayer in iOS to display large sized images with offline support as well. I need to load the tiles preview from server when internet exists, and when its not available, i need to load offline preview.

    Thanks a lot,
    Girish

    • http://www.haakseth.com/ John Wika Haakseth

      Hi! There are a number of small things that could be wrong, it’s been a while since I set this up myself, but it doesn’t sound like you’re getting an error. Check if your start center point is inside your map area:

      mapView.getController().setZoom(15); //set initial zoom-level

      mapView.getController().setCenter(new GeoPoint(52.221, 6.893));
      //This point is in Enschede, Netherlands.
      //You should select a point in your map or get it from user’s location.

      • Girish

        Thanks for the quick response :) Let me check it and update here.

      • Girish

        Its working now. You pointed it out rightly. The center point was indeed the problem. Thanks a lot John.

        • http://www.haakseth.com/ John Wika Haakseth

           Great!

  • http://twitter.com/Vlad_PSY Vlad Neghina

    Hi !

    I am trying to build your app but I am stuck with a very curious error:

    Description Resource Path Location TypeSyntax error, insert “}” to complete Block OSMDroidMapActivity.java /BvTest/src/com/yourpackage/name line 17 Java ProblemSyntax error on token “{“, { expected after this token OSMDroidMapActivity.java /BvTest/src/com/yourpackage/name line 13 Java ProblemSyntax error on token “)”, { expected after this token OSMDroidMapActivity.java /BvTest/src/com/yourpackage/name line 18 Java ProblemReturn type for the method is missing OSMDroidMapActivity.java /BvTest/src/com/yourpackage/name line 18 Java ProblemSyntax error, insert “}” to complete ClassBody OSMDroidMapActivity.java /BvTest/src/com/yourpackage/name line 17 Java ProblemmapView cannot be resolved to a type OSMDroidMapActivity.java /BvTest/src/com/yourpackage/name line 18 Java ProblemSyntax error on token “mapView”, VariableDeclaratorId expected after this token OSMDroidMapActivity.java /BvTest/src/com/yourpackage/name line 18 Java Problem

    Did you run into this issue before, or maybe you could give me some tips?

    • http://www.haakseth.com/ John Wika Haakseth

      You have to put everything between super.onCreate(savedInstanceState); and mapView.setUseDataConnection(false); in a method called onCreate(Bundle savedInstanceState). I see this was missing from the example, but I updated it now. Thanks for catching it!

  • Endi

    Hey John, great tutorial!! Some minor problems but managed to figure them out.
    I wanted to ask you, whether you have thought to use the button you create in the map, as a switch button, I mean from the offline mode to the online mode, supposing that you might want to retrieve a tile that was not originally in your zipped osmdroid file.This feature would be similar to the google maps offline functionality…please let us know, I am very interested

    • http://www.haakseth.com/ John Wika Haakseth

      Thanks! Hope it was helpful :-) The button is meant as sort of a starting point for people to add their own functionality, maybe I should post this to Github and see if someone would fork it? The idea of offline/online mode is definitely useful, but I probably wont work on it too soon as I am busy with other projects at school.

      Don’t hesitate to let me know if you keep working on it, would love to see it :-)

      • Endi

        I found out that there are some licensing problems, even with Osmdroid, they are not happy if you want to download their tiles on the go (I mean whenever the user selects an area of interest and then wants to go offline…this cannot be done, the only possibility is to have it prior downloaded on your sd card…but that’s not what i need :S) I think i have to find smth else for my project…was very enthusiastic about this idea, but cannot be done apparently, unless i want to create my own tile server ;)  

        • http://www.haakseth.com/ John Wika Haakseth

          You mean to download the tiles directly on the phone? I don’t know how that would work, and I don’t know the details of the licensing issues.

  • David in SoCal.

    Would it be possible to post a tutorial about working with the overlays in OSM?  I’ve been looking very where, but the samples I find are all posted by people who have written the code and can’t get it to work… Thx, David

    • http://www.haakseth.com/ John Wika Haakseth

      I don’t have any plans to make a tutorial on overlays at the moment. I am quite busy with other projects and school these days, but I’ll keep it in mind. Any specific topic on overlays in mind? The only “special” thing I remember doing, was to use a custom icon for the position icon.

  • Avegpatekar

    I do the the same thing as you mentioned in this tutorial but my appliaction isnot loading tiles from sd card  so it results in blank map view with zoomable control. Can u tell me any solution for this prob?

    • http://www.haakseth.com/ John Wika Haakseth

      It’s a little hard to say exactly what could be causing this in your case. The first thing I would check is to see that your starting center point of the app is within your map area:

      mapView.getController().setCenter(new GeoPoint(52.221, 6.893)); //This point is in Enschede, Netherlands. You should select a point in your map or get it from user’s location.

      Otherwise, I would look through the comments here and see if any of their issues are the same as yours.

  • Pingback: offline google map with gps for android : Android Community - For Application Development

  • http://twitter.com/hishanMdS Hishan De Silva

    do you know how to get an online mapwiew from openstreetmaps

  • http://twitter.com/hishanMdS Hishan De Silva

    Can anybody upload a working code here. Please.

  • Awais Bin Asif

    Hello, can you please tell me how to make an app with offline navigation using osmdroid api.

  • Gurucharan Vijayakumar

    Can we implement offline turn by turn navigation with this osmdroid?

  • Jim Petro

    John,
    We are trying to do something similar, we built a OSMDroid Zip file and the only way that it works is if it is in a folder named “Mapnik”. Our Zip file contains zoom levels 11 to 21, but we are only able to zoom from 11 to level 18. We are told it is because it is a mapnik limitation. Tried to change the directory name thinking it was assuming it was originally a Mapnik source and it can’t read the map. Is this directory sturcutre name hardcoded into the API?
    THanks
    JPetro@newcomtech.com

  • grave digger

    hi haak, i tried your simple tutorial but i only see the view without map. also i have an error called “Error opening trace file. No such file or directory(2)” on log cat. is this error cause my-not-showing-map problem?

  • Android Dev

    Hi, anybody can help me.. I tried this tutorial. In my case, Tile is loaded but the map view is not loading. Can any one suggest your points..

  • http://sites.google.com/site/jorgerosaportfolio Jorge Rosa

    Thankyou for this great tutorial, John! Great stuff! :)

    • Kamran

      I did same but my xml shows following error

      The following classes could not be found: – org.osmdroid.views.mapview

      • http://sites.google.com/site/jorgerosaportfolio Jorge Rosa

        Hey Kamran, I´ve just verified the code, everything runs fine here. Please double check your code.
        In your layout XML file, you must have it like this:

        In “YourActivity.java” file, you must have: import org.osmdroid.views.*;

        • Coinhunter

          Could just be that his files were in the /lib directory instead of /libs. That gave me a bit of trouble.

    • Muhammad Shehzad Arshad Virk

      where to fine these two files “slf4j-api-1.7.5.jar” and “slf4j-ext-1.7.5.jar”

    • http://www.haakseth.com/ John Wika Haakseth

      Thanks so much, I haven’t been following these comments for a few months now. Fun to see that it is still being used. Thanks for helping me answer questions. When I have time (hopefully in not to long), I will try to follow the tutorial and update it where needed.

      • http://sites.google.com/site/jorgerosaportfolio Jorge Rosa

        Thankyou for this awesome step-by-step tutorial, © John Wika ! :)

  • Kamran Ahmed

    I tried this tutorial but app force closes and gives this error in log cat : No Class Def Found Error : org.osmdroid.views.MapView

  • Nizam

    Its GREAT!!! Thanks a Ton.

  • TiagoPereira

    Hi… I do the the same thing as you mentioned in this tutorial but i cant move the map and make zoomIn or zoomOut… anybody can help me? Thanks.

  • vamsi krishna

    I do the the same thing as you mentioned in this tutorial but my
    appliaction isnot loading tiles from sd card so it results in blank map
    view with out zoomable control. Can u tell me any solution for this prob?

    Dear sir

    I copied everything /mnt/sdcard/osmdroid/OSMDroid.zip as

    and my Activity is

    MapView mapView = new MapView(this, 256); //constructor

    mapView.setClickable(true);

    mapView.setBuiltInZoomControls(true);

    setContentView(mapView); //displaying the MapView

    mapView.getController().setZoom(14); //set initial zoom-level, depends on your need

    //mapView.getController().setCenter(new GeoPoint(17.382095,78.485527)); //This point is in Enschede, Netherlands. You should select a point in your map or get it from user’s location.

    mapView.setUseDataConnection(false); //keeps the mapView from loading online tiles using network connection.

    But finally my output is following screenshot

    Sir please help me? advance Thank u sir.

  • manish

    can you tell me how to add popup window with detail and image of that point and how to change the icon of hand on search of position.

  • Coinhunter

    Any chance of a clarification of the directory to place the .zip file in?

    I’ve put my zipfile “Stockholm_2013-11-10_174332.zip” in the following directories in case one was the right one but no joy… I’m using a Samsung S4

    /DeviceName/Card/mnt/sdcard/osmdroid/
    /DeviceName/Card/sdcard/osmdroid/
    /DeviceName/Card/osmdroid/ <– i'm betting this is the intended directory.

    I get the error:

    Error downloading MapTile: /13/4096/4095
    java.lang.SecurityException: ConnectivityService: Neither user xxxx nor current process has android.permission.ACCESS_NETWORK_STATE.

    Unclear what is going wrong. Created map using the Stockholm region as you can tell by the filename, also changed the coordinates to:

    mapView.getController().setCenter(new GeoPoint(59.349033, 18.061523)); // Stockholm

    • Alvaro

      Did you find a solution. I’m having the same problem.

    • http://sites.google.com/site/jorgerosaportfolio Jorge Rosa

      For the ones with problems in download maps, internet access, and many other similar errors, first you MUST have to add these permissions in your own “AndroidManifest.xml” before run OSMdroid:

      PERMISSIONS — Just do a Copy/Paste:

      ACTIVITY — YOU MUST EDIT THIS ONE, TO FIT IN YOUR OWN PROJECT:

      NOTE: Can´t remember what exactly permissions I added specifically for OSMdroid, so there are them all ;)

  • Bank

    I can’t make it work. When I run application, it shows force close message. How can I make it work? Please give me some help T_T

  • janjack

    IS there a way to also have coordinates in longitude and latitude?That would be awesome to do some offline app using coordinates of known places

  • Bita

    where should I place map osdmdroid zip file to run my application in emulator?

    • http://sites.google.com/site/jorgerosaportfolio Jorge Rosa

      Not needed to do that. It should download the maps (and create its own folders) automatically… But only IF your PC (and emulator) have internet, of course. Then all the maps (only that ones that had been downloaded) should be available even offline.

      • gumuruh

        Hi Jorge Rosa,… is this require us to have internet connection when running the app?
        I wonder how could we implement the offline map without any internet at all?

  • ari

    why is it that my app has stopped. I follow all the steps that you’ve stated.
    what is the problem?
    Can you help me ! :D

  • ari

    so how many classes it have ?
    and what activity should I put in the AndroidManifest.xml?

  • ari

    I have a problem …
    I follow all the step but when I run my application on my device…
    the application has stopped … :(
    what do you guys was the problem !!
    Please help me out ..
    Thanks

  • Muhammad Shehzad Arshad Virk

    I do the the same thing as you mentioned in this tutorial but my appliaction isnot loading tiles from sd card so it results in blank map view with zoomable control. Can u tell me any solution for this prob?

  • Muhammad Shehzad Arshad Virk

    also when i choose mapnik its blocked like red big cros on every recangle in the mobile atlas

  • Muhammad Shehzad Arshad Virk

    i did not get any success to even view the map i would love if some one could make youtube video step by step using this tutorial thanks

    • http://sites.google.com/site/jorgerosaportfolio Jorge Rosa

      Hi Muhammad Shehzad Arshad Virk, please try to use:
      • mapview.setUseDataConnection(true);
      • mapview.setTileSource(TileSourceFactory.MAPQUESTOSM);
      The other ways (MAPNIK and DEFAULT_TILE_SOURCE) are getting a “403 Forbidden” response from theirs servers…..

      • Muhammad Shehzad Arshad Virk

        still empty grid showing tile graphe only no map view :(

      • Muhammad Shehzad Arshad Virk

        Dear jorge if i am not wrong your solution is for online map view but i need to use offline do you have any idea how to use .img file formate of a map

  • http://sites.google.com/site/jorgerosaportfolio Jorge Rosa

    DISPLAYING MAPS: A note for all OSMDroid users, before you get white hair (like me). If you get the last version (OSMDroid v.4.0) the tiles (maps) won´t display using:

    • mapview.setUseDataConnection(true);
    • mapview.setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE); // Gets a “403 Forbidden” response !!!!…
    • mapview.setTileSource(TileSourceFactory.MAPNIK); // Gets a “403 Forbidden” response !!!!…

    you MUST use, by now…

    • mapview.setUseDataConnection(true);
    • mapview.setTileSource(TileSourceFactory.MAPQUESTOSM); // Gets a server “valid” response.

    …to be able to view the maps (and save it locally in your SDCard). (Note: This issue may extend to previous versions of OSMDroid too, I haven´t tried it yet). Already being reported, so we will have to wait for a fix (or an workaround). Hopefully this issue will be fixed soon…

    Issue reported at: http://code.google.com/p/osmdroid/issues/detail?id=515

  • Muhammad Shehzad Arshad Virk

    can anyone tell how can i use .img formate of map file

  • sharsad

    i cant show the map at first time.if i zoom out 4 more times,that will show the map.and also the map not fit in screen.

  • sharsad

    how can i replace the sdcard path with my own..

    thanks

  • Tobias

    I create an example Android Studio project which describes how to prepare MapQuest tiles for offline usage with osmdroid.
    http://github.com/johnjohndoe/OSMDroidOfflineDemo