Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Turn By Turn Navigation in iOS 7

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) ?

like image 699
Virat Naithani Avatar asked Sep 26 '13 06:09

Virat Naithani


1 Answers

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];
        }
    }
}];
like image 162
mobileideafactory Avatar answered Nov 15 '22 08:11

mobileideafactory