使用iPhone的gmap中的纬度经度计算两地之间的距离 [英] Calculate distance between two place using latitude-longitude in gmap for iPhone
本文介绍了使用iPhone的gmap中的纬度经度计算两地之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能存在重复:
GPS坐标以度来计算距离
如何使用gmap for iphone中的纬度经度计算两地之间的距离?
使用gmap for iphone中的latitude-longitude计算两个地点之间的距离
#import< CoreLocation / CoreLocation.h>
CLLocation * locA = [[CLLocation alloc] initWithLatitude:lat1 longitude:long1];
CLLocation * locB = [[CLLocation alloc] initWithLatitude:lat2 longitude:long2];
CLLocationDistance distance = [locA distanceFromLocation:locB];
//以米为单位的距离
// 1米== 100厘米
// 1米== 3.280英尺
// 1平方米== 10.76平方英尺
[locA发布];
[locB发布];
Possible Duplicate:
GPS coordinates in degrees to calculate distances
How to Calculate distance between two place using latitude-longitude in gmap for iPhone? Calculate distance between two place using latitude-longitude in gmap for iPhone
解决方案
You have to use Core Location Framework. So don't forget to Add & import Core Location Framework .
#import <CoreLocation/CoreLocation.h>
CLLocation *locA = [[CLLocation alloc] initWithLatitude:lat1 longitude:long1];
CLLocation *locB = [[CLLocation alloc] initWithLatitude:lat2 longitude:long2];
CLLocationDistance distance = [locA distanceFromLocation:locB];
//distance in Meters
//1 meter == 100 centimeter
//1 meter == 3.280 feet
//1 square meter == 10.76 square feet
[locA release];
[locB release];
这篇关于使用iPhone的gmap中的纬度经度计算两地之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文