【问题标题】:How to check if google.navigation intent/url scheme is supported from within a web app?如何检查网络应用程序中是否支持 google.navigation intent/url 方案?
【发布时间】:2011-10-10 08:32:21
【问题描述】:

我想知道,使用 javascript,如果是这样的:

location = "google.navigation:q="+myDestAddress;

在实际调用它之前被支持,如果它没有恢复到普通的旧谷歌地图网址:

location = "http://maps.google.com/maps?saddr="+myStartAddress+"&daddr="+myDestAddress;

注意:我已经使用用户代理检查了该设备是 android 设备,但这还不够,据我所知,“google.navigation”意图仅在美国受支持,并且仅在某些设备/操作系统版本。

谢谢!

【问题讨论】:

  • 对于初学者,您可以检查用户代理以确保它是 Android。不知道如何自省系统以查看支持的内容:(
  • 谢谢,我没有提到,但我已经检查了用户代理,看看它是否是安卓设备。这是最简单的部分:)
  • @Sergio - 可惜这是个好问题

标签: javascript android navigation android-intent


【解决方案1】:

我想你正在寻找:

if(typeof google == "undefined" || typeof google.navigation == "undefined") {
    location = "http://maps.google.com/maps?saddr="+myStartAddress+"&daddr="+myDestAddress;
else {
    location = "google.navigation:q="+myDestAddress;
}

【讨论】:

  • 嗯,我认为 google 命名空间不可用,除非您加载他们的一些库。即使你这样做了,我也不确定定义 google.navigation 是否意味着 google.navigation 意图可用(它们是两个不同的东西)。无论如何,你有你的来源的链接,以便我检查一下吗?
猜你喜欢
  • 2010-10-12
  • 2013-12-09
  • 1970-01-01
  • 2011-06-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多