Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is an absolute minumum example project for Osmdroid which I made sometime ago.</p> <pre><code>package osmdemo.demo; 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; // This is all you need to display an OSM map using osmdroid public class OsmdroidDemoMap extends Activity { private MapView mMapView; private MapController mMapController; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.osm_main); mMapView = (MapView) findViewById(R.id.mapview); mMapView.setTileSource(TileSourceFactory.MAPNIK); mMapView.setBuiltInZoomControls(true); mMapController = mMapView.getController(); mMapController.setZoom(13); GeoPoint gPt = new GeoPoint(51500000, -150000); //Centre map near to Hyde Park Corner, London mMapController.setCenter(gPt); } } </code></pre> <p>Have this in your <code>osm_main.xml</code></p> <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" &gt; &lt;org.osmdroid.views.MapView xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/mapview" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Include <code>slf4j-android-1.5.8.jar</code> and <code>osmdroid-android-3.0.5.jar</code> in the build path. (Google search for where to get them from)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload