Android - 通过网址启动谷歌地图 [英] Android - launch google map via web url
问题描述
在 iPhone 上,一个 maps.google.com URL 被原生谷歌地图应用程序拦截并加载.我想在 Android 上做同样的事情,但浏览器中正在加载 Google 地图.
On the iPhone, a maps.google.com URL is intercepted and loaded by the native google maps application. I would like do the same on Android, but Google Maps is being loaded in the browser.
那么,在一个网页中,是否可以有这个 url http://maps.google.com/maps?saddr=brighton&daddr=timbuktu 在 Android 谷歌地图应用程序中打开?
So, in a web page, is it possible to have this url http://maps.google.com/maps?saddr=brighton&daddr=timbuktu open in the Android Google Map application ?
我从这个问题中看到你可以通过 Intent 从另一个应用程序执行此操作.你能从浏览器触发这些 Intent 吗?
I see from this question that you can do it from another app via an Intent. Can you trigger these Intent's from the browser ?
编辑 - 在进一步测试中,我发现系统会提示用户在浏览器或地图应用程序中打开指向 maps.google.maps 的标准 html 链接的链接:
Edit - On further testing, I've found that the user will be prompted to open the link in browser or map app for standard html links to maps.google.maps :
<a href="http://maps.google.com/maps?saddr=brighton&daddr=timbuktu">show route</a>
我遇到了问题,因为我使用 javascript 通过位置 API 回调设置 window.location.href(因此我可以获取用户的位置,然后打开地图).我为此打开了一个错误报告.>
I'm having the problem because I'm using javascript to set the window.location.href via a Location API callback (so I can get the user's location and then open the map). I've opened a bug report for this.
推荐答案
在地址栏中输入 geo:0,0?q=google 会打开地图活动并搜索附近的 google.
Typing geo:0,0?q=google into the address bar opens the maps activity and searches for google nearby.
我认为这可以通过页面中的链接工作,但尚未检查.
I assume this will work from a link in a page, but haven't checked.
此处提供可访问意图的完整列表:http://developer.android.com/guide/appendix/g-app-intents.html
a full list of accessible intents here: http://developer.android.com/guide/appendix/g-app-intents.html
这篇关于Android - 通过网址启动谷歌地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!