I am building an app that can open the Maps app with directions from the user’s current position to another position. The code looks like this:
- (id)resolveDirectionsFromCoordinate:(CLLocationCoordinate2D)startCoordinate toCoordinate:(CLLocationCoordinate2D)endCoordinate
{
NSString* url = [NSString stringWithFormat: @"http://maps.google.com/maps?saddr=%f,%f&daddr=%f,%f",
startCoordinate.latitude, startCoordinate.longitude,
endCoordinate.latitude, endCoordinate.longitude];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: url]];
return nil;
}
Thos works well in iOS 5.x. In iOS 6, however, this brings up Safari instead, since Maps no longer uses Google Maps.
Does anyone know which URL I should call in iOS 6?
The Apple Documentation recommends using the equivalent maps.apple.com URL Scheme
so use
instead of
to be backwards compatible your code would be
Alternatively you could also use the
maps://saddr=%f,%f&daddr=%f,%fscheme but it does not appear support the full range of parameters.