开发者

Link to iPhone map App from HTML page

开发者 https://www.devze.com 2023-03-23 17:47 出处:网络
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开发

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.


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


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消