4

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

Chris Hanson
  • 54,380
  • 8
  • 73
  • 102
Anthony Main
  • 6,039
  • 12
  • 64
  • 89
  • Seems this has already been asked: http://stackoverflow.com/questions/30058/how-can-i-launch-the-google-maps-iphone-application-from-within-my-own-native-app – Anthony Main Feb 13 '09 at 14:51

2 Answers2

10

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
  • 13,526
  • 3
  • 52
  • 57
  • 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 – Anthony Main Feb 13 '09 at 14:51
  • 1
    FYI you can just put "51.234231,-1.231232" in the saddr and daddr string if you need co-ord based lookups – Anthony Main Feb 13 '09 at 15:53
0

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

Community
  • 1
  • 1
froh42
  • 5,190
  • 6
  • 30
  • 42