【问题标题】:Start Google Maps for navigation not working when using longitude and latitude使用经度和纬度时启动谷歌地图导航不起作用
【发布时间】:2017-10-21 21:04:24
【问题描述】:

我在我的安卓应用程序中有我的经度和纬度值,我将它们传递给 url,正如官方 android 文档所说,就像这样 -

 String query_string = "google.navigation:q=" +location.getLatitude()+","+location.getLongitude();
 Uri gmmIntentUri = Uri.parse(query_string);
 Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
 //mapIntent.setPackage("com.google.android.apps.maps");
 startActivity(mapIntent);

谷歌地图可以安静地打开,但它允许说找不到路线。

我可以看到我在谷歌地图地址栏中传递的经度和纬度值。它显示“寻找最佳路线”,然后显示错误消息“未找到路线”。它也发生在所有模式(步行,驾驶......)。不知道为什么。

【问题讨论】:

  • 你能分享 lat,lng 的值吗?另外,你现在的职位是什么?您可以尝试将Google Maps URLs 作为最新(2017 年)并通过 Google 推荐的方式生成地图链接吗?
  • xomena 我在帖子中添加了一张图片
  • 为什么mapIntent.setPackage("com.google.android.apps.maps");被注释掉了?

标签: android google-maps google-maps-android-api-2


【解决方案1】:

我看过你的截图。我可以看到您尝试从当前位置查找行车路线到坐标 3.2949945,6.5993606。

但是,3.2949945,6.5993606 位于几内亚湾内的水域中。您可以在地理编码器工具中看到这一点:

https://developers-dot-devsite-v2-prod.appspot.com/maps/documentation/utils/geocoder/#q%3D3.294995%252C6.599361

我猜你的意图是找到通往 6.5993606,3.2949945 的路线:

https://developers-dot-devsite-v2-prod.appspot.com/maps/documentation/utils/geocoder/#q%3D6.599361%252C3.294995

【讨论】:

  • 是的,这就是目的。让我尝试调整我的代码并交换纬度和经度值,看看会发生什么。
  • 问题是我在程序中将经度保存为纬度,将纬度保存为经度。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-04-30
  • 1970-01-01
  • 1970-01-01
  • 2016-07-26
  • 1970-01-01
  • 2016-05-21
  • 1970-01-01
相关资源
最近更新 更多