Try the search, it's linked to some great forums

Tuesday, July 9, 2013

Turn-by-Turn Routing for your app

The following method takes the User's location and the destination's location and sends them to the iPhone's native Maps app for their Turn-by-Turn routing.  Most excellent!!

Looks like this:

The method:

- (IBAction)turnByRouting:(UIBarButtonItem *)sender {
    NSLog(@"Opens the native Map app's turn-by-turn navigation");

//business location
    // test location
    // CLLocationCoordinate2D coords = CLLocationCoordinate2DMake(37.0469,-122.0308);


// Gets the coordinates from the single pinsArray object
    NSString *latitude = [[self.pinsArray objectAtIndex:0] objectForKey:@"latitude"];
    NSString *longitude = [[self.pinsArray objectAtIndex:0] objectForKey:@"longitude"];
    CLLocationCoordinate2D coords = CLLocationCoordinate2DMake([latitude
          doubleValue], [longitude doubleValue]);
      
    MKPlacemark *place = [[MKPlacemark alloc] initWithCoordinate:coords addressDictionary:nil];
    MKMapItem *mapItem = [[MKMapItem alloc]initWithPlacemark:place];
  
//current location
    MKMapItem *mapItem2 = [MKMapItem mapItemForCurrentLocation];
      
    NSArray *mapItems = @[mapItem, mapItem2];
      
    NSDictionary *options = @{
        MKLaunchOptionsDirectionsModeKey:MKLaunchOptionsDirectionsModeDriving,
        MKLaunchOptionsMapTypeKey:[NSNumber numberWithInteger:MKMapTypeStandard],
        MKLaunchOptionsShowsTrafficKey:@YES
    };      
    [MKMapItem openMapsWithItems:mapItems launchOptions:options];
}