Lat,Long 值不准确到 iphone 中的当前位置
Posted
技术标签:
【中文标题】Lat,Long 值不准确到 iphone 中的当前位置【英文标题】:Lat,Long values are not accurate to the current location in iphone 【发布时间】:2013-01-31 09:16:40 【问题描述】:我是 ios 新手,现在我正在开发定位应用程序,但在 iPhone 上运行我的应用程序时,我没有得到正确的纬度、经度值。它给了我当前位置的纬度、经度值太远,为什么它会显示这些值谁能告诉我..
【问题讨论】:
Trouble with CLLocation method distanceFromLocation: Inaccurate results的可能重复 感谢您的回复.. 现在它工作正常 【参考方案1】:试试看……
设置委托 CLLocationManagerDelegate
#import <CoreLocation/CoreLocation.h>
CLLocationManager *locationManager;
CLLocation *startLocation;
- (void)viewDidLoad
[super viewDidLoad];
NSString *currentLatitude;
NSString *currentLongitude;
locationManager = [[CLLocationManager alloc] init];
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
locationManager.delegate = self;
[locationManager startUpdatingLocation];
startLocation = nil;
-(void)locationManager:(CLLocationManager *)manager
didUpdateToLocation:(CLLocation *)newLocation
fromLocation:(CLLocation *)oldLocation
currentLatitude = [[NSString alloc]
initWithFormat:@"%g",
newLocation.coordinate.latitude];
currentLongitude = [[NSString alloc]
initWithFormat:@"%g",
newLocation.coordinate.longitude];
NSLog(@"%@",currentLatitude);
NSLog(@"%@",currentLongitude);
-(void)locationManager:(CLLocationManager *)manager
didFailWithError:(NSError *)error
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"ERROR" message:[NSString stringWithFormat:@"%@",error] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
[alert release];
【讨论】:
以上是关于Lat,Long 值不准确到 iphone 中的当前位置的主要内容,如果未能解决你的问题,请参考以下文章
计算由 lat,long 表示的两点之间的距离,精度高达 15 英尺