Skip to content

Instantly share code, notes, and snippets.

@rhysforyou
Created July 13, 2012 09:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save rhysforyou/3103893 to your computer and use it in GitHub Desktop.
Save rhysforyou/3103893 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