Reputation: 294
NSString *url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f", currentLocation.latitude, currentLocation.longitude, coordinate.latitude, coordinate.longitude];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
I am trying open Maps application on iPhone from my application to show direction between two location. But, it is showing written directions in safari from google rather than opening maps application. Can anybody help me out.
Upvotes: 1
Views: 738
Reputation: 50697
You can launch other apps from your app. However, maps should respond to the http://maps.google.com schema. Typically, http://maps.google.com/ should launch the Maps application but I'm not sure why it is not.
Maps also supports maps://
and mapitem://
URL Schemes.
The iOS Simulator does not have the Maps app, so obviously this isn't going to work in the simulator. Works as expected on a physical device though.
Upvotes: 3