Hello Friends,

For more than 2 weeks, i was working to use OSM Offline map in Android application. I have gone through many articles, blogs and question/answers of Stackoverflow, but could not find the solutions. still i am at the stage where i was earlier.

Using maperitive.net, i have downloaded Map tiles of India for 2-12 Zoom level. i have given the name to the root folder is Mapnik and Mapnik.zip for its zip file. i have copied the file at /sdcard/osmdroid folder.

Below is code of my android app :

Manifest file :

alt text

Layout file

alt text Java file :

public class MainActivity extends Activity {

    private MapView         map;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

        map = (MapView) findViewById(R.id.mapview);
        map.setUseDataConnection(false);
        map.setTileSource(TileSourceFactory.MAPNIK);
        map.setTileSource(new XYTileSource("Mapnik",
                ResourceProxy.string.mapnik, 2, 12, 256, ".png", new String[] {}));

        map.setBuiltInZoomControls(true);
        map.setMultiTouchControls(true);

        IMapController mapController = map.getController();
        mapController.setZoom(10);
        GeoPoint startPoint = new GeoPoint(22.8583, 72.2944);
        mapController.setCenter(startPoint);

    }

    @Override
    protected void onResume() {
        super.onResume();

    }
}

asked 24 Oct '17, 08:19

Ashish7's gravatar image

Ashish7
11112
accept rate: 0%


Basically I believe that you are taking the wrong approach and you should be looking at mapsforge or similar vector data based system for rendering on device instead of generating tiles.

As to your question, some debug information would be helpful, but from your code you don't seem to be telling osmdroid where your tiles are located and other required setup.

There is a demo app here https://github.com/johnjohndoe/OSMDroidOfflineDemo that may help.

permanent link

answered 24 Oct '17, 12:00

SimonPoole's gravatar image

SimonPoole ♦
38.3k13284608
accept rate: 19%

edited 24 Oct '17, 13:33

@simonpoole, I had already followed the https://github.com/johnjohndoe/OSMDroidOfflineDemo link and its steps, Mobile Atlas Creator is banned and it is not generating any Map tile. so i have taken the help of maperitive.net to generate tiles. but could not get success. i can get only blank grids on mobile screen.

please help me out. it would be good if you share latest working code snippet or let me know what i did in my above code or steps

(25 Oct '17, 07:23) Ashish7
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×161
×40
×28

question asked: 24 Oct '17, 08:19

question was seen: 3,387 times

last updated: 25 Oct '17, 07:23

powered by OSQA