I am trying to create an app that uses offline maps and custom tiles. For this I have decided to use OSMDroid and have included the jar within my project. I will create my c
This one worked for me:
setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE);
as did:
setTileSource(TileSourceFactory.MAPNIK);
I didn't need to have anything in the the XML
It's coming back to be now, I had to add one of these:
to the manifest.xml.
I can't remember which one was necessary but if you put all 3 in, it should work.
Well here's my entire source, which I've just run on the emulator:
package com.nbt.osmdroidtest;
import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
import org.osmdroid.util.GeoPoint;
import org.osmdroid.views.MapController;
import org.osmdroid.views.MapView;
import android.app.Activity;
import android.os.Bundle;
public class OsmDroidTest extends Activity {
/** Called when the activity is first created. */
private MapController mapController;
private MapView mapView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mapView = (MapView) findViewById(R.id.mapview);
mapView.setTileSource(TileSourceFactory.MAPNIK);
mapView.setBuiltInZoomControls(true);
mapController = mapView.getController();
mapController.setZoom(15);
GeoPoint point2 = new GeoPoint(51496994, -134733);
mapController.setCenter(point2);
}
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
}
Give it a minute or so to load, as initially it might be quite slow in building up a cache. Those coordinates should put you over central London. If you still have problems see if there is anything illuminating in the logcat.
And the main.xml