简体   繁体   English

MapKit-如何使用MapKit在我的iPhone应用程序中实现从源和目标的指示?

[英]MapKit - How can I implement directions from Source and Destination in my iphone app using MapKit?

How can i get the shortest distance from source A to Destination B using the MapKit in iphone. 如何使用iPhone中的MapKit获得从源A到目标B的最短距离。 Is there any way to implement this? 有什么办法可以实现呢? Thank you. 谢谢。

Assuming that you are looking for routing, you need to fetch the routes from a routing server. 假设您正在寻找路由,则需要从路由服务器获取路由。 Check Google directions API. 检查Google Directions API。 CloudMade also has routing api. CloudMade还具有路由api。 I don't think MapKit provides a way to fetch routes and find shortest distance. 我认为MapKit无法提供一种获取路线并找到最短距离的方法。

If you are looking for straight line distance use: 如果您正在寻找直线距离,请使用:

CLLocation *aLocation = …
CLLocation *differentLocation = …
[aLocation distanceFromLocation:differentLocation];

For route mapping, I'm pretty sure the best option is still to fire up the maps application appropriately parameterised.... 对于路线映射,我敢肯定,最好的选择仍然是启动已适当参数化的maps应用。

Try here http://mobile.tutsplus.com/tutorials/iphone/iphone-sdk-quick-tip-launching-maps-in-app/ 在这里尝试http://mobile.tutsplus.com/tutorials/iphone/iphone-sdk-quick-tip-launching-maps-in-app/

Thanks 谢谢

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM