I tried to make an osmdroid project using Android Studio but any map is shown. I have just a blanck grid.
In my xml file I put the folowing code :
<?xml
version="1.0" encoding="utf-8"
?>
<LinearLayout
xmlns:android="..."
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<org.osmdroid.views.MapView
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
tilesource="Mapnik"
/>
</LinearLayout>
in my .java file I made this onCreate method
private MapView mMap;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
mMap = (MapView) findViewById(R.id.map);
mMap.setMultiTouchControls(true);
mMap.setBuiltInZoomControls(true);
}
IMapController mapController = mMap.getController();
mapController.setZoom(14);
mapController.setCenter(new GeoPoint(48.745, -3.455));
ScaleBarOverlay scala = new ScaleBarOverlay(mMap);
mMap.getOverlays().add(scala);
mMap.invalidate();
And I added the following permissions in the manifest:
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"
/>
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"
/>
<uses-permission
android:name="android.permission.ACCESS_WIFI_STATE"
/>
<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE"
/>
<uses-permission
android:name="android.permission.INTERNET"
/>
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
/>
Do you know how can I solve this problem ?
I used osmdroid-android:5.6.4' (and I tried also other versions but I have the same problem with all)
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…