1

in My iPhone App How Can I show directions from current location to End Point?

is there any built in component or facility available on iphone which can show maps and direction using GPS and built in compass?

ios
  • 6,134
  • 20
  • 71
  • 103
  • Refer to these links http://stackoverflow.com/questions/1944710/google-maps-api-driving-directions http://stackoverflow.com/questions/5102286/iphone-google-maps-directions Hope this helps. – Parth Bhatt Sep 30 '11 at 05:20
  • what if I want to show this directions in my app by using the MKMap..!? –  Nov 06 '11 at 21:33

3 Answers3

6

If you mean taking the user to the maps application based on two points, then you can do it like this:

  1. Create an NSURL that looks like this: NSURL *URL = [NSURL URLWithString:@"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f"]; You plug in your starting address and destination (in lat. and long.) appropriately.
  2. Tell your application to open the URL [[UIApplication sharedApplication] openURL:URL];

It should take you to the maps application automatically!

Mason
  • 6,893
  • 15
  • 71
  • 115
  • When I run this in the iPhone 5.0 simulator, it opens the safari version of the google maps. Is there a difference in running this simulator vs. actual device? – x89a10 Feb 21 '13 at 20:48
0

try this:-

NSString *urlstring=[NSString stringWithFormat:@"http://maps.google.com/?saddr=%f,%f&daddr=%f,%f",sourcelocation.latitude,sourcelocation.longitude,destinationlocation.latitude,destinationlocation.longitude];

[[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlstring]];
Gypsa
  • 11,230
  • 6
  • 44
  • 82
0
NSString *Urlstring=[NSString stringWithFormat:@"http://maps.google.com/?saddr=%@&daddr=%@",from_address,to_address];

[[UIApplication sharedApplication]openURL:[NSURL URLWithString:urlstring]];

This will give clear direction mentioning the source address and destination address.

Ramdhas
  • 1,765
  • 1
  • 18
  • 26
Rama Rao
  • 1,043
  • 5
  • 22