问题描述
我想在地图上的两个位置之间绘制一条路线.像导游一样的东西.当游客点击另一个位置时,我希望能够绘制一条路线;并告知与当前位置的距离.
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.
我知道Internet上的站点告诉您如何在地图上绘制折线.但是,大多数示例中都预先加载了带有各种坐标的.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.矢量流服务器应返回所需的内容,然后可以在地图上绘制该内容.但是,Googlemade和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中绘制路线的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!