[英]how to improve accuracy of Lat long using Core location manager
[英]Improve Accuracy of Location Manager in iOS Programming
我正在制作一個跟蹤用戶的應用程序。 我注意到當應用程序在后台運行時,然后在您打開應用程序時,直到大約5秒鍾,它才為用戶顯示錯誤的當前位置。 是否有要解決的問題,因為5秒鍾的延遲會破壞跟蹤結果(無緣無故地增加了3英里)。
編輯:問題實際上不是一個“錯誤”。 我必須在我的Info.plist中設置我想要后台處理並繁榮應用程序跟蹤,這是超級准確的。 一些教程可以做到這一點:
您可以做的一件事是檢查要返回的CLLocation
上的horizontalAccuracy
屬性。 如果該值高於某個閾值,則可以丟棄結果,然后等待更准確的結果。 如果距離數英里,那么我希望准確度數值會很大。 最有可能使用小區站點而不是GPS來確定位置,並且誤差幅度會更大。
在CLLocationManagerDelegate
的locationManager:didUpdateLocations:
方法中,您可以執行以下操作:
- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
if ([locations count] > 0) {
CLLocation *lastUpdatedLocation = [locations lastObject];
CLLocationAccuracy desiredAccuracy = 1000; // 1km accuracy
if (lastUpdatedLocation.horizontalAccuracy > desiredAccuracy) {
// This location is inaccurate. Throw it away and wait for the next call to the delegate.
return;
}
// This is where you do something with your location that's accurate enough.
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.