Did you ever wonder why Apple didn't provide a way to show directions directly on top of MKMapView and force you to switch to their built-in Maps.app just to guide your users somewhere? We too, that's why we built MTDirectionsKit. Switching to Maps.app just to show directions results in a context-switch and can confuse your users, thus increasing the chance that they won't return to your Application.
MTDirectionsKit is a full-featured and easy to use solution to show directions in your App, directly on top of MKMapView. Not only will your users thank you for not throwing them out of your App, it will also distinguish your App from all the others that don't offer this functionality.
Convinced? Let's get you started.
MTDirectionsKit can use the following three APIs for gathering routing information:
You can find a demo application here: MTDirectionsKit Demo
Full documentation is available here: MTDirectionsKit Documentation
MTDirectionsKit is very easy to use, here's a sample call:
MTDMapView *_mapView = [[MTDMapView alloc] initWithFrame:self.view.bounds]; // ... // setup _mapView // ... // configure MTDirectionsKit (optional) // log more messages MTDDirectionsSetLogLevel(MTDLogLevelInfo); // change used API to Google Directions MTDDirectionsSetActiveAPI(MTDDirectionsAPIGoogle); // manually change measurement system // Warning: MTDirectionsKit automatically sets it to the preferred one of the user's device, // only override if you have a really good reason to MTDDirectionsSetMeasurementSystem(MTDMeasurementSystemMetric); // set the delegate of MKMapView. This automatically sets the directionsDelegate, if self // conforms to the protocol MTDDirectionsDelegate _mapView.delegate = self; [_mapView loadDirectionsFrom:CLLocationCoordinate2DMake(51.38713, -1.0316) to:CLLocationCoordinate2DMake(51.4554, -0.9742) routeType:MTDDirectionsRouteTypeFastestDriving zoomToShowDirections:YES];
To see a detailed example on how to use MTDirectionsKit have a look at the provided Demo Application.
There are two ways to integrate MTDirectionsKit into your App:
The easiest way to integrate MTDirectionsKit is to add the binary framework to your App.
Independent of which way to integrate MTDirectionsKit you choose, you have to add some system frameworks and libraries to your project. For MTDirectionsKit to work you have to add
CoreLocation.framework MapKit.framework libxml2.dylib
to your target's linked libraries (found under Build Phases, see pictures below).
Just drag MTDirectionsKit.framework onto the Frameworks-group of your App, add
everywhere you want to use it and you are good to go.
![MTDirectionsKit.framework](http://f.cl.ly/items/3x0F1L400f3r1T142p14/MTDirectionsKit_Framework.png "Binary Framework")
First copy the whole MTDirectionsKit project into your applications root folder and use this project for the following steps:
You are good to go, just
everywhere where you want to use it.
![MTDirectionsKit.xcodeproj as Dependency](http://f.cl.ly/items/3D40042w200D0a3u0h0R/MTDirectionsKit_Dependency.png "Dependency")
MTDirectionsKit needs Xcode ≥ 4.5, iOS Base SDK ≥ 5.1 and Clang LLVM = 3.1 to compile. It doesn't work with the old LLVM GCC compiler.
MTDirectionsKit works on a deployment target of ≥ iOS 4.3 and can be used in ARC or non-ARC applications.