MTDirectionsKit
Overview
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:
- MapQuest Open Directions API
- Google Directions API
- [Bing Routes API] (http://msdn.microsoft.com/en-us/library/ff701705.aspx "Bing Routes API")
You can find a demo application here: MTDirectionsKit Demo
Full documentation is available here: MTDirectionsKit Documentation
MTDirectionsKit is very easy to use, here's sample code:
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:
- Include the binary framework MTDirectionsKit.framework
- Add MTDirectionsKit.xcodeproj as a dependency
The easiest way to integrate MTDirectionsKit is to add the binary framework to your App. For this just drag MTDirectionsKit.framework onto the Frameworks-group of your App and add
#import <MTDirectionsKit/MTDirectionsKit.h>
Everywhere you want to use it. Additionally 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).
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.
More iOS item
Hotel App Template
Database Storage SQLite
Color Shapes Rush - Unbelivable Price

