我使用的顺序以下条件,以确保我得到的位置有足够的精度,在我的情况kCLLocationAccuracyBest。但问题是,我仍然得到不准确的位置。

// Filter out nil locations
if(!newLocation)
    return;

// Make sure that the location returned has the desired accuracy
if(newLocation.horizontalAccuracy < manager.desiredAccuracy)
    return;

// Filter out points that are out of order    
if([newLocation.timestamp timeIntervalSinceDate:oldLocation.timestamp] < 0)
    return;

// Filter out points created before the manager was initialized
NSTimeInterval secondsSinceManagerStarted = [newLocation.timestamp timeIntervalSinceDate:locationManagerStartDate];
if(secondsSinceManagerStarted < 0)
    return;

// Also, make sure that the cached location was not returned by the CLLocationManager (it's current) - Check for 5 seconds difference
if([newLocation.timestamp timeIntervalSinceReferenceDate] < [[NSDate date] timeIntervalSinceReferenceDate] - 5)
    return;

当我激活GPS,我得到不准确的结果之前,我确实得到一个精确的结果。什么方法,你用得到精确的/精确的位置信息?

有帮助吗?

解决方案 2

主要原因我是越来越不准确的结果是,因为此条件:

if(newLocation.horizontalAccuracy < manager.desiredAccuracy)

我用kCLLocationAccuracyBest作为desiredAccuracy,这是一个负数。你不应该使用它进行比较。

解决方案: if(newLocation.horizontalAccuracy < 10.0)

其他提示

GPS是缓慢的,至少比用户的耐心,所以外景经理返回最佳它,直到它到达一个新的,有效的GPS读取。您可以让用户等待然而多长时间才能得到一个准确的读取,或者有某种增量反馈谷歌的方式映射呢,比一个点一个圆圈。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top