Maps.app is not opening programmatically

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.

Answers


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.

Update

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.


Need Your Help

How to shade a monochrome image

image postscript eps

How can my Postscript draw a monochrome (black/white) image embedded from an EPS file such that the black parts of the image are displayed at 50% value?

How do I run a method when a model gets created?

python django

Currently I am using signals to fireoff the creation of my IPs when a new Subnet is created.