I am writing an Android App and want to show an OSM map. I tried the tutorial, but the map is empty all the time.
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import org.osmdroid.api.IMapController;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapView;
public class MainActivity extends AppCompatActivity {
/** Called when the activity is first created. */
private IMapController mapController;
private MapView mapView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mapView = (MapView) findViewById(R.id.map);
mapView.setTileSource(TileSourceFactory.MAPNIK);
mapView.setMultiTouchControls(true);
mapController = mapView.getController();
mapController.setZoom(15);
GeoPoint poin1 = new GeoPoint(48.8583, 2.2944);
mapController.setCenter(point1);
}
}
I use osmdroid 4.3.
Thanks in advance, Plebo
If you are targeting API23 and running on a 23+ emulator, then you must prompt the user for permissions. See the sample app from v5.1 or newer. You'll also need some kind of local storage for the tile cache.