2012-04-03 160 views
0

我們的應用程序存在與地圖位置有關的問題。Android谷歌地圖顯示舊位置

加載地圖屏幕時,地圖會在屏幕上顯示最後一個GPS位置,這可能不準確。有時從GPS獲取更新的位置信息需要相當長的時間,並且有時會直接失敗。

無論在哪種情況下,用戶都會收到來自最後一個已知位置的不準確位置信息。我們應該避免這...

我們需要能夠顯示進度條或微調到用戶,而GPS信息更新,只有然後在地圖上顯示新的更新位置。

我們怎樣才能做到這一點,非常感謝,提前感謝。

回答

0

覆蓋OnLocationChanged方法。無論您在實施LocationListener的..

像這樣: -

private class MyLocationListener implements LocationListener{ 

    public void onLocationChanged(Location argLocation) { 
    GeoPoint myGeoPoint = new GeoPoint(
    (int)(argLocation.getLatitude()*1000000), 
    (int)(argLocation.getLongitude()*1000000)); 

    GeoPoint newGeoPoint = new GeoPoint(myGeoPoint.getLatitudeE6(), myGeoPoint.getLongitudeE6()); 
    Toast.makeText(GetApplicationContext(),"Lat:"+newGeoPoint.getLatitudeE6()/1000000,"Lang:"+newGeoPoint.getLongitudeE6()/1000000) 
    } 

希望它會幫助你..