I'm working on an event app and I'm trying to add a "Get directions" button that opens up directions in either Apple Maps or Google Maps. I'm happy to use Apple maps for now because it's easy to embed with http://maps.apple.com/?q=XYZ()
.
My app is displaying an HTML website with a UIWebView
, so this may be the problem, but when you press the link it actually opens within the UIWebView
and displays Google Maps randomly but accurately. Is there a function I can put into my HTML code that forces the link to open in the native Apple or Google Maps?
COMPLETE ANSWER
CODE:
PLIST PROPERTIES:
BUTTON
1X
2X
3X
Instead of using the
http
protocol in your URL, try using themaps
protocol instead, so that your link looks something like:You can also open it in Google Maps, if the user has it installed, by using a URL such as:
Though you might get unexpected results if the user doesn't have it installed.
If this doesn't work, it's possible to use the UIWebView delegate method
webView:shouldStartLoadWithRequest:navigationType:
to intercept links and open the Maps application properly.Here you can find info on the Google Maps URL Scheme
Will enforce Google Maps to be used. You might want to do
first, to ensure that Google Maps is available. If not, simply call your regular
to open apple maps.