Draw a path between two coordinates in MapView (iOS) [duplicate]

旧巷老猫 提交于 2019-12-08 06:49:54

问题


Possible Duplicate:
Show route between current and desired location on iPhone MapView

I am trying to draw a path between two coordinates on a MapView in iOS, but I can't figure out how. I have the two latitude and longitude points in one view.

How can I draw the path between these two points? I've attached the example with this question. Please help me. Any tutorials and code will be appreciated!


回答1:


A simple answer is; you can't. At least, not using the built in API methods of iOS.

As far as i've seen so far, you have three alternatives:

  1. Use an external library that offers such functionality - i'm sure there are plenty to be found on GitHub.

  2. Compile the appropriate url and open mobile safari pointing to Google Maps with a directions request.

  3. Use the built in methods of iOS 5/6 to open your route in the native Maps.app

I've used the third method in an app and this works fine but does come with the disadvantage that users will have to leave your application when viewing directions in Maps. It does however remain consistent and not quite as jarring to the user than opening mobile Safari.

If you do find a way to do this inside your own app, i'd be interested in seeing your results.



来源:https://stackoverflow.com/questions/12883016/draw-a-path-between-two-coordinates-in-mapview-ios

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!