tags:

views:

2898

answers:

3

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

A: 

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 :-)

froh42
A: 

Question was already asked here

http://stackoverflow.com/questions/30058/how-can-i-launch-the-google-maps-iphone-application-from-within-my-own-native-app

just provide the correct url.

Andy Jacobs
+4  A: 

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]];
Jane Sales
Thanks this looks like what, I need, sorry for missing that other post I had searched first. Just need to get it to take co-ords now, but should be able to crack that from googlemaps itself
tigermain
FYI you can just put "51.234231,-1.231232" in the saddr and daddr string if you need co-ord based lookups
tigermain