javascript - How to generate a location link that will open in default mapping app? - Stack Overflow

I am writing a simple little web app in JS an want to generate links to locations (latlon) that will o

I am writing a simple little web app in JS an want to generate links to locations (lat/lon) that will open in a mobile user's default, native mapping app (vs opening in browser).

e.g. Maps on iOS, Google Maps on Android, etc

Any best practices to acplish this?

I am writing a simple little web app in JS an want to generate links to locations (lat/lon) that will open in a mobile user's default, native mapping app (vs opening in browser).

e.g. Maps on iOS, Google Maps on Android, etc

Any best practices to acplish this?

Share Improve this question asked Feb 24, 2013 at 15:02 Geoff DudgeonGeoff Dudgeon 311 silver badge3 bronze badges 4
  • I don't believe that there is any sort of "geolocation" standard tag attribute; I'm not even sure what tag it'd involve. An <a> tag has to have a URL if it's going to do anything, so perhaps it'd be some sort of "location" URL scheme. Perhaps somebody else knows. – Pointy Commented Feb 24, 2013 at 15:05
  • ... something like this I guess, which looks like a good start but I've never seen it in use. – Pointy Commented Feb 24, 2013 at 15:06
  • ... and then there's this Stackoverflow question with a link to an IETF proposal for something essentially similar. – Pointy Commented Feb 24, 2013 at 15:09
  • ... and hey check this out! – Pointy Commented Feb 24, 2013 at 15:11
Add a ment  | 

2 Answers 2

Reset to default 3

You can make use of the url scheme and generate a link like this. When the user clicks on the link, it should open a native mapping app instead.

<a href="googlemaps://?center=40.765819,-73.975866&zoom=14&views=traffic">Open map</a>

Here is the references:

iOS map http://developer.apple./library/ios/#featuredarticles/iPhoneURLScheme_Reference/Articles/MapLinks.html

Google map in iOS https://developers.google./maps/documentation/ios/urlscheme

Google map in Android http://developer.android./guide/appendix/g-app-intents.html

Hope these links can help you.

I also have a similar requirement in one of my projects.I did something like this:

<a href=geo:latitude,longitude></a>

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744313115a4568046.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信