Geo: Protocol on iPhone Safari

2019-03-20 20:16发布

问题:

The geo: URI scheme doesn't seem to work for me on the iphone safari browser. Has anyone had any luck implementing this? Here is an example piece of code:

<a href="geo:39.555551,-82.814171;">Test</a>

The above works on android phones... are there any alternatives to this? Thanks for the help!

回答1:

The geo: scheme, being relatively new, isn't supported by any builtin apps on iOS. (It's a good idea for a feature request, though.)

One alternative (supported all the way back to iPhone OS 1.0) is to use a Google Maps URL. For example: http://maps.google.com/maps?ll=37.331044,-122.029202 -- this will get automatically redirected to the Maps application. (I dunno if or how this might change with the forthcoming non-Google-backed Maps in iOS 6, though.)

It's also possible to register a third-party app to handle URL schemes not used by system apps, so you could create your own geo handler if that's useful to you.



回答2:

On my iPhone (ios6), the google earth app opens the geo: link. For native google maps app support, I use the comgooglemaps: scheme, and apple maps will open if you click a 'normal' http://maps.apple.com/ link.



回答3:

You can also handle this in pure Javascript. Its easiest using Dojo, jQuery or some other JS library that offers delegated event support.

https://github.com/prowestgis/dojo-geo-uri-polyfill