[SalesForce] How to open the native iOS maps app from a Visualforce page in Salesforce1

I have a Visualforce page that displays Account addresses. I would like to create a link to open the native iOS Maps app. I've tried using the following and it doesn't appear to work:

https://developer.apple.com/library/ios/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html#//apple_ref/doc/uid/TP40007899-CH5-SW1

<a href="http://maps.apple.com/?q=cupertino">Cupertino</a>

The link in my Visualforce page does nothing.

UPDATE: I had poorly encoded data in the url string. So now the link does open, however, it redirects to a google map. Is there a way to launch the iOS app or at least prompt the user to allow it?

Best Answer

I believe the best way would be to use javascript. Then o'click determine how to proceed. Something like this will be your core javascript function. Note using the maps:// will open in iOS, then any other device would open on google maps. Gives you the most flexibility and a fallback to Google Maps.

if( (navigator.platform.indexOf("iPhone") != -1) 
    || (navigator.platform.indexOf("iPod") != -1)
    || (navigator.platform.indexOf("iPad") != -1))
     window.open("maps://maps.google.com/maps?daddr=lat,long&amp;ll=");
else
     window.open("http://maps.google.com/maps?daddr=lat,long&amp;ll=");
Related Topic