Chapter 8
How to Get Direction and Draw Route on Maps
Since the release of the iOS 7 SDK, the MapKit
framework includes the MKDirections
API which allows iOS developers to access the route-based directions data from Apple's server. Typically you create an MKDirections
instance with the start and end points of a route. The instance then automatically contacts Apple's server and retrieves the route-based data.
You can use the MKDirections
API to get both driving and walking directions depending on your preset transport type. If you like, MKDirections
can also provide you alternate routes. On top of all that, the API lets you calculate the travel time of a route.
Again we'll build a demo app to see how to utilize the MKDirections
API. After going through the chapter, you will learn the following stuff:
- How to get the current user's location
- How to use
#available
to handle multiple versions of APIs - How to compute the route and draw it on the map
- How to use the segmented control
- How to retrieve the route steps and display the detailed driving/walking instructions
To continue reading and access the full version of the book, please get the full copy here. You will also be able to access the full source code of the project.