osm地图加载错误

时间:2012-05-14 07:57:11

标签: android osmdroid

我想在openstreetmap中查看地图。我添加了osmdroid-android-3.0.8和slf4j-android-1.5.8,我给了以下权限......

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION"></uses-permission>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>

我的代码........

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(13);
    GeoPoint gp=new GeoPoint(51500000, -150000);
    mapcontroller.setCenter(gp);
}

但我得到空地图并在LogCat中收到错误....

下载MapTile时出错。 java.lang.SequrityException:ConnectivityService:用户10034和当前进程都没有android.permission.ACCESS_NETWORK _...

我该如何解决?

1 个答案:

答案 0 :(得分:2)

//您需要在清单中添加此使用权限

//并确保您在google api中运行

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"></uses-permission>