0

I have an application with an Osmdroid-MapView, whose data is stored in an off-map on the device: /mnt/sdcard/osmdroid/tiles.zip

Structure of the zip file:

+-- MapquestOSM
+-- 10
¦ +-- 550
¦ +-- 335.png
...

My goal: I want to store different offline maps and a certain then can be selected in the program.

My problem: in what form do I have to store the maps in the osmdroid folder and how can I tell Osmdroid my choice?

Part of source:

protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.activity_main);
  MapView mapView = (MapView) findViewById(R.id.mapview);
  mapView.setClickable(true);
  mapView.setBuiltInZoomControls(true);
  mapView.setMultiTouchControls(true);
  mapView.setUseDataConnection(true);
  mapView.setTileSource(TileSourceFactory.MAPQUESTOSM);

  IMapController mapViewController = mapView.getController();
  mapViewController.setZoom(15);
  mapViewController.setCenter(BERLIN);
}

Please help !

Regards Wicki

user3589211
  • 89
  • 2
  • 13

1 Answers1

1

Unfortunately, you can't really force osmdroid to load one specific zip.

What you can do is play with the XYTileSource name, as it must match with your root directory name inside the zip file:

map.setTileSource(new XYTileSource("Map_1",
    ResourceProxy.string.mapquest_osm, 0, 18, 256, ".png", new String[] {
        "http://otile1.mqcdn.com/tiles/1.0.0/map/",
        "http://otile2.mqcdn.com/tiles/1.0.0/map/",
        "http://otile3.mqcdn.com/tiles/1.0.0/map/",
        "http://otile4.mqcdn.com/tiles/1.0.0/map/"}));

will only use zip files structured like this:

+-- Map_1
+-- 10
¦ +-- 550
¦ +-- 335.png
...

Also refer to: Download maps for osmdroid

Community
  • 1
  • 1
MKer
  • 3,430
  • 1
  • 13
  • 18
  • Well if you approved my pull request, we could :) – spy Sep 15 '15 at 22:56
  • Actually, not mker. Sorry had you mixed up with the osmdroid guy – spy Sep 16 '15 at 00:26
  • This works fine. Is it possible to specify different XYTileSource names (with the accompanying tiles) in 1 zip-file ? – user3589211 Sep 16 '15 at 13:42
  • If you put a "Map_1" entry and a "Map_2" entry inside the same zip file? And then you call either XYTileSource("Map_1", ... ) or XYTileSource("Map_2", ... )? Yes, I think it should work. – MKer Sep 16 '15 at 21:06
  • A word of warning for any big size the .zip performance starts to get very bad. Look at gemf where the format has been designed for the job. Same sort of issue on the names and file position though. – Ifor Sep 18 '15 at 07:34