views:

67

answers:

2

I am trying to use a URL to launch the native maps application. My build is for 3.1.3 and later. When I run the following code, safari launches with the URL instead of google maps:

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://maps.google.com/maps"]];

Any suggestions?

Thanks!

A: 

Your string needs to be @"maps://maps.google.com/...". That "maps" at the front of it is what triggers it to load the Maps.app application.

Dan Ray
If you read the apple documentation, you'll see that this is explicitly mentioned as wrong.
DexterW
http://developer.apple.com/iphone/library/featuredarticles/iPhoneURLScheme_Reference/Articles/MapLinks.html
DexterW
Huh! I'd swear I've done that successfully in the past... Thanks for the correction.
Dan Ray
+2  A: 

It sounds to me like you are running on the simulator not hardware. This behavior occurs when the map app is not installed or if you are on the simulator.

If you are running on hardware - have you tried that same style with a specific query or location or with http://maps.google.com as the documentation you pointed to mentions that The path cannot be /maps/*. - I'm not sure if that means explicitly *. or if they mean a wildcard. I'm not really clear why you'd want to launch the map app without a specific query.

Nick