Anthony Main
Anthony Main

Reputation: 6068

How to link to Google Map directions from iPhone app

I have been developing a location based application and would ideally like to link directly to the directions using the Google application.

I have seen a few applications such as AroundMe which already seem to do this but I can't work out how they have managed to implement it

Upvotes: 4

Views: 9534

Answers (2)

Jane Sales
Jane Sales

Reputation: 13546

The question was about opening maps with the navigation directions displayed, not just the map. The iPhone's URL scheme supports a source & destination address - try, for example:

NSString* urlString = @"http://maps.google.com/maps?saddr=London+UK&daddr=Birmingham+UK";
[[UIApplication sharedApplication] openURL:[NSURL URLWithString: urlString]];

Upvotes: 10

user60229
user60229

Reputation:

Use OpenURL to start google maps with the correct location, just like described in this question on stackoverflow.

Extract from there: Use

[someUIApplication openURL:[[NSURL alloc] initWithString: @"http://maps.google.com/maps?g=London"]]

instead of g=London you can also use more for the URL format to drop pins, or move to a GPS location (possibly the current location you previously got from your application by asking core location)

Unrelated:

Please comment if somebody has a suggestion on how to handle duplicate and or/related questions on stack overflow. I'm still new around here :-)

Upvotes: 0

Related Questions