2

我是 osmdroid 的新手,试图在 android 中显示地图,它没有显示地图,只显示空白的瓷砖,也没有显示缩放控制。

我的代码:

public class MainActivity extends Activity {

private MapView m_mapView; 
private int MAP_DEFAULT_ZOOM = 16; 
private double MAP_DEFAULT_LATITUDE =  33.6667; 
// Default map Longitude: 
private double MAP_DEFAULT_LONGITUDE = 73.1667;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main); 
    m_mapView = (MapView) findViewById(R.id.mapview); 
   // m_mapView.setTileSource(TileSourceFactory.MAPQUESTOSM); 
    m_mapView.setTileSource(TileSourceFactory.MAPNIK);
    m_mapView.setBuiltInZoomControls(true); 
    m_mapView.setMultiTouchControls(true); 
    m_mapView.setClickable(true); 
    m_mapView.setUseDataConnection(true); 
    m_mapView.getController().setZoom(16); 
   m_mapView.getController().setCenter(new GeoPoint(33.6667, 73.1667)); 
}

我已经在 AndroidManifest、xml 中添加了这个

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_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-feature android:name="android.hardware.location.network" />
<uses-feature android:name="android.hardware.location.gps" />   
<uses-feature android:name="android.hardware.wifi" />
4

1 回答 1

1

您必须将此添加到您的AndroidManifest.xml

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
于 2013-12-25T12:50:18.237 回答