Behy
Behy

Reputation: 483

osmdroid: How to load offline map from sdcard to MapView

I have generated a set of maps, zipped it under name tiles.zip and copied in sdcard/osmdroid folder. Here are atlas setting and folder content.

enter image description here

enter image description here

I used the example project here. It runs without error but my maps are not presented in MapView. Here is MainActivity and layout:

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;


public class MainActivity extends AppCompatActivity {

    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.MAPQUESTOSM);
       IMapController mapViewController = mapView.getController();
       mapViewController.setZoom(15);
       mapViewController.setCenter(BERLIN);


    }
}

and

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="${packageName}.${activityClass}">

    <org.osmdroid.views.MapView
        android:id="@+id/mapview"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:clickable="true" />

</RelativeLayout>

As I tested, if I unzip the maps and add them as assets, maps are shown but in wrong order.

any idea what's wrong? thanks

EDIT1

Here my log:

enter image description here

Upvotes: 0

Views: 1586

Answers (1)

Ladislav Hofman
Ladislav Hofman

Reputation: 91


1) Do you have Berlin in your zoom level 15 tiles? If not, try to set zoom level to 1 or change map center to your region.
2) you do not need to create so many layers in MOBAC. Just select you area, zoom levels and add it at once. It might help. Other setting are same like in my project

Upvotes: 1

Related Questions