Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iphone google maps - direction using latitude and longitude

I'm working on iphone app. I know my current location (latitude and longitude) and destination's (latitude and longitude). How can I use "Google maps" to find the directions. URL for google maps is something like "http://maps.google.com/maps?daddr=San+Francisco,+CA&saddr=cupertino"
From above URL, inspite of source and destination places i want to use latitude and longitude. how?

like image 928
Satyam Avatar asked May 09 '10 12:05

Satyam


2 Answers

NSString* url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f",
                                            currentLocation.coordinate.latitude, currentLocation.coordinate.longitude, 
                                            destLocation.coordinate.latitude, destLocation.coordinate.longitude];

[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];
like image 122
s1mm0t Avatar answered Oct 05 '22 23:10

s1mm0t


Rob is right.

You can do something like below, just providing the Destination ( or start address )

http://maps.google.com/maps?daddr=-37.8218956215849,144.9599325656891

Or even

http://maps.google.com/maps?saddr=-37.8218956215849,144.9599325656891&daddr=-37.8218956215849,144.9599325656891

It's just replacing start & end with the lat/langs.

http://maps.google.com/maps?saddr=start&daddr=end

like image 20
DrexiL Avatar answered Oct 06 '22 00:10

DrexiL