Cry*_*tal 3 iphone cllocationmanager ios
我开始乱用CLLocationManager,我正在尝试使用下面的回调方法.我去外面在我的iPhone上测试它,并且在最初的几次更新中,我似乎得到了胡言乱语的价值,就像突然我的距离是39米,即使我没有移动到任何地方.或者有时它会从5开始,然后跳到20米,再没有我移动到任何地方.我走到外面走了,从最初的起点开始的更新似乎"没问题",然后当我走回去时,我回到原来的39米起点.我想知道我在下面做的是否正确.我还包括了我的viewDidLoad方法,我初始化了我的CLLocationManager对象.
有没有办法确保我的第一个值是准确的?提前致谢.
- (void)viewDidLoad
{
[super viewDidLoad];
locationManager = [[CLLocationManager alloc] init];
locationManager.delegate = self;
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
}
- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
{
if (startingPoint == nil) {
NSLog(@"NIL starting point");
self.startingPoint = newLocation;
}
CLLocationDistance distance = [newLocation distanceFromLocation:startingPoint];
NSString *distanceString = [[NSString alloc] initWithFormat:@"%g m", distance];
distanceLabel.text = distanceString;
[distanceString release];
numberOfUpdates++;
NSString *countString = [[NSString alloc] initWithFormat:@"%d", numberOfUpdates];
countLabel.text = countString;
[countString release];
}
Run Code Online (Sandbox Code Playgroud)
GPS是一种不完美的技术.大气条件,卫星可用性(和位置),天空能见度,从附近物体(建筑物)反弹的信号都会导致其固有的不准确性.虽然甚至有一个"准确度"值(通常很好) - 即使这不是完全可靠的.
飞机不允许使用GPS进行精确进近 - 即使它们的接收器不够精确,也需要其他技术(有自己的问题).
尝试运行标准的"地图"应用程序并将其用作比较.我认为你的代码很好 - 这是突然的GPS.
我当然是这样说的,因为我正在研究自己的海事导航应用程序,我自己也遇到了所有这些问题.
归档时间: |
|
查看次数: |
4406 次 |
最近记录: |