我正在开发一个健身追踪应用程序,如 Runtastic、Nike+ 等。我将从头到尾绘制整个活动的地图。我不会在应用程序启动时开始更新位置更改,而是在用户开始锻炼时开始更新。但是当 locationManager 开始更新时,前 3 到 5 个 CLLocations 是非常不正确的。误差高达一公里。我正在使用以下代码来初始化位置管理器:
self.locationManager = [(PFAppDelegate *)[[UIApplication sharedApplication] delegate] locationManager];
self.locationManager.delegate = self;
self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
self.locationManager.distanceFilter = 5.0;
[self.locationManager startUpdatingLocation];
在 locationManagerDidUpdateToLocation 方法中:
if( didFindGPS == NO )
{
if( [[lastLocation timestamp] timeIntervalSinceNow] < 10.0 )
{
if( [lastLocation horizontalAccuracy] < 20)
{
didFindGPS = YES;
}
}
}
else
{
//process data here
}
这不会过滤掉那些第一个不正确的位置。我也尝试过忽略horizontalAccury 值小于20 的位置,但是应用程序不会处理任何位置。
可以做些什么来改进第一个位置或处理第一个不正确的位置?