iphone - 根据道路计算两个位置之间的距离

标签 iphone objective-c ios mkmapview core-location

我有两个 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/

相关文章:

使用 ASI 的 iOS 应用程序在将编译器切换到 Apple LLVM 后显示大量 'redefinition'

ios - 拖动 View Controller 而不是滑动手势

ios - 如何更改coredata中的记录顺序?

iphone - 为什么此音频单元RemoteIO初始化可在iPhone上但不能在模拟器中使用?

ios - View Controller "embed"本身如何在 UINavigationController 中 - 特别是当包含在容器 View Controller 中时

objective-c - 如何将 UTF-8 字符添加到 NSString?

iphone - 使用 NSFileManager 复制文件期间更新进度条

Objective-C:从 NSString 生成 NSArray

ios - 分享扩展状态栏样式

ios - Swift 2.2 如何更改选项卡栏 Controller 的背景颜色