Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This one worked for me:</p> <pre><code>setTileSource(TileSourceFactory.DEFAULT_TILE_SOURCE); </code></pre> <p>as did: </p> <pre><code>setTileSource(TileSourceFactory.MAPNIK); </code></pre> <p>I didn't need to have anything in the the XML</p> <p>It's coming back to be now, I had to add one of these:</p> <pre><code>&lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"&gt;&lt;/uses-permission&gt; &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/&gt; &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt; </code></pre> <p>to the manifest.xml.</p> <p>I can't remember which one was necessary but if you put all 3 in, it should work. </p> <p>Well here's my entire source, which I've just run on the emulator:</p> <pre><code>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; } } </code></pre> <p>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.</p> <p>And the main.xml</p> <pre><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:id="@+id/mapview" android:layout_width="fill_parent" android:layout_height="fill_parent" android:clickable="true" /&gt; &lt;/LinearLayout&gt; </code></pre>
 

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