Reputation: 783
I am working on a navigation app to show turn by turn driving directions. In iOS 6 we have to pass data to ios map app, but i want to show it without leaving the app.
Apple has introduced new directions API in iOS 7, so now in iOS 7 is it possible to show Turn By Turn Navigation within the app(in MKMapView) ?
Upvotes: 6
Views: 2855
Reputation: 1670
In iOS 7, you can use something like this to render driving direction within your app:
MKDirectionsRequest *request = [[MKDirectionsRequest alloc] init];
[request setSource:[MKMapItem mapItemForCurrentLocation]];
[request setDestination:myMapItem];
[request setTransportType:MKDirectionsTransportTypeAny];
[request setRequestsAlternateRoutes:YES];
MKDirections *directions = [[MKDirections alloc] initWithRequest:request];
[directions calculateDirectionsWithCompletionHandler:^(MKDirectionsResponse *response, NSError *error) {
if (!error) {
for (MKRoute *route in [response routes]) {
[myMapView addOverlay:[route polyline] level:MKOverlayLevelAboveRoads];
}
}
}];
Upvotes: 2
Reputation: 11779
this page can be helpful for you if you want to render paths between two locations. As an alternative you can also use Googles directions API which is accepted by apple.
http://iosguy.com/tag/directions-api/
https://developers.google.com/maps/documentation/directions/
Upvotes: 0