Link to iPhone map App from HTML page

不羁岁月 提交于 2019-11-29 08:34:28

问题


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.


回答1:


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.




回答2:


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




回答3:


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.




回答4:


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.



来源:https://stackoverflow.com/questions/6840769/link-to-iphone-map-app-from-html-page

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!