需要帮助来提高宽容度和经度精度
我使用以下代码:
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
其中 locationManager
是类 CLLocationManager
的对象。
当我提取经纬度时只要:
lat = [[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.latitude];
longt=[[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.longitude];
NSLog(@"latitude is:%@",lat);
NSLog(@"longitude is: %@", longt);
那么它打印为:
纬度为:30.6807 经度为:76.726
但我确实需要
纬度:57.645800 经度:11.896000
如您所见,两种情况下小数点都以 00 结尾。
我怎样才能做到这一点?
感谢
iPhone 开发者
I'm using the below code:
locationManager.distanceFilter = kCLDistanceFilterNone;
locationManager.desiredAccuracy = kCLLocationAccuracyBest;
Where locationManager
is an object of class CLLocationManager
.
When I'm extracting the lat & long as:
lat = [[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.latitude];
longt=[[NSString alloc] initWithFormat:@"%g", newLocation.coordinate.longitude];
NSLog(@"latitude is:%@",lat);
NSLog(@"longitude is: %@", longt);
then it prints as:
latitude is:30.6807 longitude is: 76.726
but I do need as
Lat: 57.645800 Long: 11.896000
As you see the decimal ends with 00 in both cases.
How can I do that??
Thanks
iPhoneDeveloper
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试使用,
因为纬度和经度以双精度形式返回。
You can try using
as latitude and longitude are returned as double.
使用 NSNumber 来存储纬度和经度。然后在 NSLog 中使用 %f 和 NSNumber 的 doubleValue 属性。 NSNumber 或 NSDecimalNumber 将为您提供最大精度。
use NSNumber to store the latitude and longitude. then in NSLog use %f and doubleValue property of NSNumber. NSNumber or NSDecimalNumber will give you maximum precision.