0
我正在使用osmdroid顯示MAPNIK中的地圖並將地圖的中心設置爲特定位置 該applcation沒有錯誤地工作,但地圖位於遠從我的代碼especified點,我設置的位置,距離我需要這樣,我不想從DDMS發送它們的代碼(lat和長),我的代碼是:位置不準確,並在DDMS中產生異常
Double latitude = 15.610793;
Double longitude = 32.540152;
int lat = (int) (latitude * 1E6);
int lng = (int) (longitude * 1E6);
GeoPoint myPoint = new GeoPoint(lat, lng);
// show first message
Toast toast = Toast.makeText(getBaseContext(),
"latitude is :"+lat+"lng is: "+lng, Toast.LENGTH_LONG);
toast.show();
mapView = (MapView) this.findViewById(R.id.mapView);
mapView.setTileSource(TileSourceFactory.MAPNIK);
mapView.setBuiltInZoomControls(true);
mapView.setMultiTouchControls(true);
mapController = mapView.getController();
mapController.setCenter(myPoint);
mapController.setZoom(15);
,我也在模擬器中有這個錯誤:
[2012-06-16 00:05:21 - ddms] null
java.lang.NullPointerException
at com.android.ddmlib.Client.sendAndConsume(Client.java:573)
at com.android.ddmlib.HandleHello.sendHELO(HandleHello.java:142)
at com.android.ddmlib.HandleHello.sendHelloCommands(HandleHello.java:65)
at com.android.ddmlib.Client.getJdwpPacket(Client.java:672)
at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:317)
at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263)
[2012-06-16 00:05:21 - ddms] null
java.lang.NullPointerException
at com.android.ddmlib.Client.sendAndConsume(Client.java:573)
at com.android.ddmlib.HandleHello.sendHELO(HandleHello.java:142)
at com.android.ddmlib.HandleHello.sendHelloCommands(HandleHello.java:65)
at com.android.ddmlib.Client.getJdwpPacket(Client.java:672)
at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:317)
at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263)
sor Ÿ我的錯誤不是例外,正如我所說,它是在控制檯標籤:DDMS,所以該應用程序工作正常,不會崩潰
我還注意到,當我在谷歌API的模擬器測試它的位置是acurate,我不知道爲什麼? –
您必須使用Google API才能使用我認爲的MapView。 – FoamyGuy
我siad我使用osmdroid API,這意味着,我不需要GAPI –