我有两个 MKCoordinateRegion
对象。基于这些对象的值,我在 map 上做了两个 annotations
。
然后我计算这两个位置之间的距离:
CLLocationCoordinate2D pointACoordinate = [ann coordinate];
CLLocation *pointALocation = [[CLLocation alloc] initWithLatitude:pointACoordinate.latitude longitude:pointACoordinate.longitude];
CLLocationCoordinate2D pointBCoordinate = [ann2 coordinate];
CLLocation *pointBLocation = [[CLLocation alloc] initWithLatitude:pointBCoordinate.latitude longitude:pointBCoordinate.longitude];
float distanceMeters = [pointBLocation distanceFromLocation:pointALocation];
distanceMeters = distanceMeters / 1000;
但我不确定我得到的值是否正确。
这些值是空中距离吗?
是否有可能根据道路获得距离?
我需要用户的距离必须开车过去。
最佳答案
这些值是空气距离。
您无法使用 Apple SDK 根据道路找到距离。尝试直接询问 google APIs http://code.google.com/intl/fr-FR/apis/maps/index.html
关于iphone - 根据道路计算两个位置之间的距离,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8428633/