views:

50

answers:

1

So I have an iPhone app which should aid the user to find a convenient walkway from his/her own position to a given destination. As I have learnt, MKMapView does not provide an easy way to infer a preferred walking route from A to B.

I can live with terminating my own app and launch the native map application on the iPhone, but in that case I would like to equip the map application with two coordinates so that the user can find his/her way.

Any suggestions to how I should go about this task?

+3  A: 

To launch the native map app use:

NSString *googleMapsURL = [NSString stringWithFormat:@"http://maps.google.com/?saddr=%1.6f,%1.6f&daddr=%1.6f,%1.6f",
                               start.latitude, start.longitude, destination.latitude, destination.longitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:googleMapsURL];

where start is the user location and destination is, well, the destination. For walking directions, you can add &dirflg=w (still in beta according to wiki). Here are some more parameters you can use.

Felixs
Works like a charm, thanks, but I really would prefer to open the native map iPhone application, not open the Google API in the safari browser. But maybe the walkway part isn't so easily achieved there?
maralbjo
That code should open in the native map application, and does for me.
Felixs
My bad. Of course it opens in the native map app. Thanks for the perfect answer.
maralbjo