Вопрос

I prepared this simple project to test the offline map functionality of osmdroid. In the first step I use the Internet connection to download tiles. Everything works as expected. The following code snippet shows the settings for the activity containing the map view.

public class MainActivity extends Activity {

    public static final GeoPoint BERLIN = new GeoPoint(52.516667, 13.383333);

    @Override
    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.MAPNIK);

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

}

Now I want to manually supply a archive file containing the tile bitmaps. These are the steps I did to prepare for offline mode:

  1. I zip the existing folders on the sdcard which can be found in /mnt/sdcard/osmdroid/tiles/.
  2. I place the resulting Mapnik.zip one level above in /mnt/sdcard/osmdroid/.
  3. I delete all the cached tiles in /mnt/sdcard/osmdroid/tiles/Mapnik.

Now I turn off the wireless connection on the phone and restart the application. No map tile shows up. Why?

Это было полезно?

Решение

You're supposed to use the tile packager to create your zip, or mobile atlas creator. However, if you rename all the *.tile files in your zip to *.png, it should work (not tested).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top