Skip to content

Instantly share code, notes, and snippets.

@danielphillips
Forked from rhysforyou/gist:3103893
Created September 16, 2012 23:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielphillips/3734823 to your computer and use it in GitHub Desktop.
Save danielphillips/3734823 to your computer and use it in GitHub Desktop.
- (IBAction)showWalkingDirections:(id)sender {
if ([self.parkingDetails.mapItem respondsToSelector:@selector(openInMapsWithLaunchOptions:)]) {
NSDictionary *launchOptions = @{
MKLaunchOptionsDirectionsModeKey : MKLaunchOptionsDirectionsModeWalking,
MKLaunchOptionsMapTypeKey : [NSNumber numberWithInt:MKMapTypeStandard]
};
[self.parkingDetails.mapItem openInMapsWithLaunchOptions:launchOptions];
} else {
NSString *mapURL = @"http://maps.google.com/maps?";
mapURL = [mapURL stringByAppendingFormat:@"saddr=%f,%f&",
self.mapView.userLocation.location.coordinate.latitude,
self.mapView.userLocation.location.coordinate.longitude];
mapURL = [mapURL stringByAppendingFormat:@"daddr=%f,%f&",
self.parkingDetails.location.coordinate.latitude,
self.parkingDetails.location.coordinate.longitude];
mapURL = [mapURL stringByAppendingFormat:@"dirflg=w"];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:mapURL]];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment