Posted By

espinallab on 04/19/10


Tagged

google map MapKit


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

umang_nine
Tintenklecks


Show Directions on Google Map in the iPhone.


 / Published in: Objective C
 

URL: http://www.espinallab.com

Here is a peace of code from one of my project to show you how you to show directions on the Google Map application.

  1. - (void)showDirections {
  2. if ([self.address length] == 0) return;
  3. //We create our link to the appDelegate
  4. ClubPlanetControllerAppDelegate * appDelegate = (ClubPlanetControllerAppDelegate *)[UIApplication sharedApplication].delegate;
  5.  
  6.  
  7. NSURL *myURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://maps.google.com/maps?daddr==%@&saddr=%f,%f", [self.address stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding], [appDelegate.lat floatValue], [appDelegate.lon floatValue]]];
  8. [[UIApplication sharedApplication] openURL:myURL];
  9. }

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: clearbrian on June 30, 2010

daddr== should be daddr=

Use local version of google maps to improve search change http://maps.google.com to http://maps.google.co.uk to localise search to UK .fr for france etc

Posted By: clearbrian on June 30, 2010

other parameters us can pass in url to improve search http://mapki.com/wiki/GoogleMapParameters

You need to login to post a comment.