Is there a “map:” URI prefix to launch map application? (like mailto: or tel:)

徘徊边缘 提交于 2019-12-18 03:06:55

问题


Is there such prefix for launching map application on phones,

<a href="map:21st,High Street, London">Toto's home</a>

like can do

<a href="mailto:toto@gmail.com">Toto's mail</a>

回答1:


geo: is an officially-recognised URI scheme, and maps: may be implemented in some clients.

https://en.wikipedia.org/wiki/Geo_URI_scheme




回答2:


In each plantform:

Apple

Documentation

Example: <a href="http://maps.apple.com/?ll=12.34567,8.90123">

Android:

Documentation

Example: <a href="geo:40.726966,-74.006076">

Windows Phone:

Documentation

Example: <a href="bingmaps:?cp=40.726966~-74.006076">




回答3:


Both of the previous answers are correct in their own way but did not provide a succinct example.. So here goes:

Use:

  <a href="geo://?q=My+address+here">View On Map</a>

Works on Android & Apple in my tests.




回答4:


I don't have enough of a reputation to add a comment to ryan knell's answer above but, having recently implemented a geo uri feature into the Share panel of the OpenStreetMap site, I'd like to point out that there's no "//" in that scheme. It's spelled out quite clearly, with examples, in RFC 5870.




回答5:


Apple uses link with the maps:// protocol now too, as far as I know, only Apple Maps supports it (tested on Mac OSX 10.11 El Captain).

Example: maps://maps.apple.com/maps?daddr=48.851925,2.337141

So, to list them all, there are the protocols: geo:, bingmaps:, maps:, or linking to the various websites, eg: https://goo.gl/maps/VZG3rV6cRGE2.




回答6:


If you simply do this...

<a href="http://maps.apple.com/?q=123+Main+etc...">View on map</a>

If the browser is on iOS/Mac, the native maps app will launch (doesn't matter the browser). If on android/windows/other, maps.apple.com will redirect to maps.google.com

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



来源:https://stackoverflow.com/questions/10769631/is-there-a-map-uri-prefix-to-launch-map-application-like-mailto-or-tel

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