我使用CLLoction管理器來獲取location.but當我開始我的位置,然後它給了我oldLocation這是以前存儲在設備中。我想重置這個我第一次啓動使用標誌的位置應用程序我使用newlocation並調用stopupdateinglocation和startupdatinglocation方法。但oldlocation沒有改變它顯示舊的位置。CLLocation manager給我舊的位置
1
A
回答
6
每個CLLocation
都有一個timestamp
屬性,您可以使用它來過濾所有位置更新,這些位置更新對於您的使用來說太舊了。
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
NSTimeInterval age = [newLocation.timestamp timeIntervalSinceNow];
if(age < SOME_CONSTANT_IN_SECONDS)
{
//Use location
}
}
0
你不能清除舊的位置,但你可以檢查horizontalAccuracy,知道這是一個很好的位置(當前)還是舊的和不相關的。
+0
oldlocation意思是說,如果我開始我的應用程序和GPS獲取協調和步行5KM後,我再次開始我的應用程序,GPS舊位置是以前的位置。我計算距離我的應用程序顯示5KM移動,但我開始我的應用程序,並沒有移動。 – user226284
+1
使用時間戳。 – 2009-12-14 08:27:45
相關問題
- 1. CLLocation Manager中斷
- 2. AFNetworking和CLLocation Manager iOS
- 3. CLLocation Manager應該自動開始更新位置
- 4. CLLocation Manager(如何啓用「使用當前位置」)
- 5. CLLocation Manager代表未調用?
- 6. CLLocation Manager startUpdatingLocation不啓動
- 7. CLLocation manager超時問題
- 8. CLLocation Manager代理問題
- 9. CLLocation Manager不提示用戶
- 10. CLLocation,獲得新的位置
- 11. CLLocation當前位置獲取位置
- 12. CLLocation GeoFire位置時間
- 13. cllocation跟蹤一個位置
- 14. CLLocationManager不給我我的位置
- 15. CLLocationManger給出了舊的位置。如何獲得新的位置?
- 16. 在iOS6的委託比較舊的位置與新位置
- 17. 位置管理器給舊位置帶新時間戳
- 18. [CLLocation]和CLLocation之間的差異
- 19. CLLocation EXC_BAD_ACCESS
- 20. 爲AVD Manager指定android api的位置
- 21. CLLocationManager是給老位置
- 22. CLLocation Manager didStartMonitoringForRegion不調用的代理方法
- 23. AFNetworking與CLLocation給出錯誤
- 24. CLLocation速度
- 25. CLLocation位於CLLocationCoordinate2D在swift中
- 26. Xamarin Android SDK Manager不保存位置
- 27. locationListener + manager與GoogleServices +位置客戶端
- 28. SDK Manager不顯示較舊的API
- 29. 憋屈CLLocation
- 30. UIBarbuttonItemStyle - CLLocation
我無法在上述方法的swift代碼中獲取舊位置。有什麼方法可以獲得舊的位置嗎? –