在 iOS 的 MapKit 中绘制路线 [英] Drawing a route in MapKit in iOS

查看:47
本文介绍了在 iOS 的 MapKit 中绘制路线的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在地图上的两个位置之间绘制一条路线.有点像导游.当游客点击另一个位置时,我希望能够绘制路线;以及,告知与当前位置的距离.

I want to draw a route between two locations on the map. Something like a tour guide. When the tourist clicks another location, I want to be able to draw a route; as well as, inform about the distance from the current location.

我知道互联网上有一些网站告诉我如何在地图上绘制折线.但是,大多数示例都有一个带有各种坐标的预加载 .csv 文件.

I am aware of sites on the Internet which tell how to draw polylines on map. But, most of the examples had a preloaded .csv file with various coordinates.

是否有其他方法可以从 Google 或任何其他提供商处获取坐标,因为位置是动态选择的.

Is there an alternative way to get the coordinates from Google or any other provider, as the location is selected dynamically.

如果没有,我如何获得中间坐标的信息?

If NO, how do I get the information for intermediate coordinates?

iOS 6 是否提供了解决此问题的任何直接方法?

Does iOS 6 provide any direct way for this problem?

推荐答案

这是一个棘手的问题.MapKit 没有办法做到这一点:当您知道坐标时,绘制线很容易,但 MapKit 不会让您访问道路或其他路线信息.我会说你需要调用一个外部 API 来获取你的数据.

This is a tricky one. There is no way to do that with MapKit: it's easy enough to draw lines when you know the coordinates, but MapKit won't give you access to the roads or other routing information. I'd say you need to call an external API to get your data.

我一直在玩 cloudmade.com API.矢量流服务器应该返回您需要的内容,然后您可以在地图上绘制它.但是,Google 地图与 cloudmade 使用的 OSM 地图之间的差异可能会让您想要使用cloudmade 地图一路:他们有一个等价于 MapKit.

I've been playing with cloudmade.com API. The vector stream server should return what you need, and then you can draw that over your map. However, discrepancies between the Google maps and the OSM maps used by cloudmade may make you want to use cloudmade maps all the way: they have an equivalent to MapKit.

P.S.:其他地图提供商 - Google、Bing 等也可能提供等效的数据馈送.我最近在看 OSM/Cloudmade.

P.S.: Other mapping providers - Google, Bing, etc. may also provide equivalent data feeds. I've just been looking at OSM/Cloudmade recently.

P.P.S.:这些都不是小菜一碟!祝你好运!

P.P.S.: None of this is trivial newbie stuff! Best of luck!

这篇关于在 iOS 的 MapKit 中绘制路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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