문제 설명
mapView에서 길찾기 버튼을 만드는 방법은 무엇입니까? (How to create get direction button in mapView?)
I am working on my app, it has the mapView inside and the user location. Then, I need to get direction from user location to particular place on the map, how do I do that. I'am searching around and it seem to be like that Apple does not allow to do it on Apple map. Please give me some advices and thanks so much.
참조 솔루션
방법 1:
As John commented, you can't get directions via a UIMapView
, as Apple doesn't provide an API you can use to do so. If you really need an API for directions and don't want to write it yourself, check out the following APIs:
- MapQuest
- CloudMade
- Google Directions Web API
Using one of the listed sources, you can make an HTTP
request to a server that will return a result (likely in JSON
) that includes both directions and an ETA.
For example, the following MapQuest API call will return a JSON
item called distance
, which contains the formatted distance (in miles) that the recommended route between Lancaster and York will take. Just remember to pass in your API key.
http://www.mapquestapi.com/directions/v1/route?key=YOUR_KEY_HERE&from=Lancaster,PA&to=York,PA&callback=renderNarrative
For further explanation, have a look at the MapQuest documentation.
(by Kuc Ku、The Kraken)