iOS:两个位置之间的路线距离(路线,而不是直线) [英] iOS: distance of route between two locations (route, not straight line)

查看:332
本文介绍了iOS:两个位置之间的路线距离(路线,而不是直线)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有多个注释的MKMapview。当用户选择注释时,标注视图显示位置的名称以及位置与用户位置之间的距离。



我被困在距离。在iOS 5之前,我可以使用Google方向API来获取距离,但现在我不能。有没有其他解决方案?



谢谢!



编辑:



我所指的距离是两个地点之间路线的距离。路线有很多路线。 distanceFromLocation:的结果不是直线的距离

解决方案

现在(iOS 7及更高版本)获取MKDirections,MKDirectionsRequest和MKDirectionsResponse的路由。



路线信息是MKRoute(有一个距离属性)。



例如按照此链接


I have a MKMapview with multiple annotations. When the user chooses an annotation, the "callout" view shows the location's name and the distance between the location and the user location.

I'm stuck at getting the distance. Prior to iOS 5, I could use Google direction API to get the distance, but now I can't. Is there any alternative solution?

Thank you!

EDIT:

The distance I refer is the distance of the route between two locations. The route has many routes. It's not the distance of the straight line as the result of "distanceFromLocation:"

解决方案

Now (iOS 7 and later) you can get a route with MKDirections, MKDirectionsRequest and MKDirectionsResponse.

The route information is MKRoute (there's a distance property).

For an example follow this link.

这篇关于iOS:两个位置之间的路线距离(路线,而不是直线)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆