10

Is there a way to link to directions in the iPhone map app from a html page?

We're placing an add in an iPhone app which will link to a mobile page on our website - we'd like to add a directions link, thus far google searches have been unrevealing.

toomanyairmiles
  • 6,465
  • 8
  • 43
  • 71

4 Answers4

13

A link to http://maps.google.com/maps will automatically open in the map application

You can set a destination address (daddr) and start address (saddr) in the link:

http://maps.google.com/maps?daddr=San+Francisco,+CA&saddr=cupertino

You can see some more options at:

https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html

Cœur
  • 37,241
  • 25
  • 195
  • 267
fchasen
  • 445
  • 4
  • 12
6

Here is a javascript function that creates the link:

function mapLink(myAddress) {
    return 'http://maps.google.com/maps?q='+escape(myAddress);
}

This works great on the iPhone.

goferteeth
  • 76
  • 1
  • 1
4

If you use the standard link that would display a map in the browser, it will automatically open in Google Maps on the device. That includes links that show directions.

Kendall Helmstetter Gelner
  • 74,769
  • 26
  • 128
  • 150
2

Use something like:

<a href='maps:daddr=<destination>&saddr=Current%20Location'>Directions</a>

where may be a lat/lon pair (separated by a comma) or a place. Ensure you URI encode the destination to ensure it works.

greencustard
  • 249
  • 1
  • 3
  • can you show an example with an actual address? I am trying to do this but the map application always returns back with an error? – Joseph Astrahan Nov 30 '13 at 23:56