如何使用iPhone CLLocationManager获取精确坐标

如何使用iPhone CLLocationManager获取精确坐标,iphone,Iphone,我正在使用CLLocationManager*locationManager获取坐标,但这些坐标与谷歌地图坐标不完全相同 // MyCLController.h // mapCurrentLocation // // Created by mac on 18/11/11. // Copyright 2011 __MyCompanyName__. All rights reserved. iPhone坐标如下所示 +/-100.00米(速度-1.00 mps/航向-1.00) 相

我正在使用CLLocationManager*locationManager获取坐标,但这些坐标与谷歌地图坐标不完全相同

 //  MyCLController.h
 //  mapCurrentLocation
 //
 //  Created by mac on 18/11/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
iPhone坐标如下所示 +/-100.00米(速度-1.00 mps/航向-1.00)

相同设备位置的谷歌地图坐标如下

谷歌地图的坐标是对的,但iPhone的坐标是错的,它们离谷歌地图的精确坐标有100米远

 //  MyCLController.h
 //  mapCurrentLocation
 //
 //  Created by mac on 18/11/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
我怎样才能得到准确的坐标呢

 //  MyCLController.h
 //  mapCurrentLocation
 //
 //  Created by mac on 18/11/11.
//  Copyright 2011 __MyCompanyName__. All rights reserved.
//

#导入
@协议MyCLControllerDelegate
@必需的
-(void)位置更新:(CLLocation*)位置;
-(无效)位置错误:(N错误*)错误;
@结束
@接口MyCLController:NSObject{
IBUILabel*位置标签;
CLLocationManager*locationManager;
id代表;
}
@财产(非原子,保留)CLLocationManager*locationManager;
@属性(非原子,赋值)id委托;
-(无效)locationManager:(CLLocationManager*)经理
DidUpdateLocation:(CLLocation*)newLocation
fromLocation:(CLLocation*)oldLocation;
-(无效)locationManager:(CLLocationManager*)经理
错误:(n错误*)错误;
@结束
//
//MyCLController.m
//mapCurrentLocation
//
//mac于2011年11月18日创建。
//版权所有2011年uu MyCompanyName uuu。版权所有。
//
#导入“MyCLController.h”
@MyCLController的实现
@综合定位经理;
@综合代表;
-(id)init{
self=[super init];
if(self!=nil){
self.locationManager=[[[CLLocationManager alloc]init]autorelease];
self.locationManager.delegate=self;//将loc更新发送给我自己
}
回归自我;
}
-(无效)locationManager:(CLLocationManager*)经理
DidUpdateLocation:(CLLocation*)newLocation
fromLocation:(CLLocation*)oldLocation
{
//NSLog(@“位置:%@,[新位置描述]);
[self.delegate location更新:newLocation];
}
-(无效)locationManager:(CLLocationManager*)经理
didFailWithError:(n错误*)错误
{
//NSLog(@“错误:%@,[错误描述]);
[self.delegate locationError:error];
}
-(无效)解除锁定{
[self.locationManager发布];
[super dealoc];
}
@结束
在这里我使用这个类--
#导入“mapCurrentLocationViewController.h”
@mapCurrentLocationViewController的实现
/*
//指定的初始值设定项。覆盖以执行加载视图之前所需的设置。
-(id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil{
self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
如果(自我){
//自定义初始化
}
回归自我;
}
*/
-(无效)viewDidLoad{
locationController=[[MyCLController alloc]init];
locationController.delegate=self;
[locationController.locationManager startUpdatingLocation];
}
-(无效)位置更新:(CLLocation*)位置{
locationLabel.text=[位置描述];
}
-(无效)位置错误:(N错误*)错误{
locationLabel.text=[错误描述];
}
-(无效)解除锁定{
[位置控制器释放];
[super dealoc];
}
@结束

要获得尽可能精确的位置测量值,请设置
locationManager.desiredAccuracy=KCallocationAccuracyBest在您
startUpdatingLocation
之前


另外,检查传递到
locationManager:didUpdateToLocation:fromLocation:
CLLocation
对象的
时间戳和
水平精度。如果位置测量看起来比您希望的更老或更不准确,请设置计时器并等待更多的位置测量结果。核心位置通常会快速提供缓存和/或不精确的位置,然后再进行更精确的精确位置测量。

那么,您目前是如何获得坐标的?您至少需要显示一些代码。-(void)viewDidLoad{locationController=[[MyCLController alloc]init];locationController.delegate=self;[locationController.locationManager startUpdatingLocation];}-(void)dealloc{[locationController release];[super dealloc];}-(void)locationUpdate:(CLLocation*)location{locationLabel.text=[位置描述];}-(void)locationError:(NSError*)error{locationLabel.text=[错误描述];}在MyCLController类中,我定义委托并创建CLLocationManager*locationManager的对象。该类取自示例。编辑您的帖子并使用代码标记将代码粘贴到其中,在注释部分很难阅读它。