【问题标题】:Send to Google Maps with one Location使用一个位置发送到 Google 地图
【发布时间】:2014-10-01 08:32:46
【问题描述】:

我正在开发一个 Android 应用,我需要为用户提供到达某些地方的路线。我有这些地方的坐标,但我发现很难获得用户的当前位置,绕过这个我想知道我是否可以将用户发送到谷歌地图,只显示他想要到达的地方的坐标,谷歌地图会给出给用户的正确方向还是我必须指定他的位置?

【问题讨论】:

    标签: android eclipse google-maps coordinates


    【解决方案1】:

    这是我刚刚发现的一个 hack,可以实现你想要的。

    String directionsUrl = "https://www.google.co.in/maps/dir/'" + sourceLat + "," + sourceLng + "'/'" + destLat + "," + destLng + "'/";
    

    然后只需使用Intent 打开 URL。

    Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(directionsUrl));
    startActivity(intent);
    

    然后 Android 会提供可以执行该操作的应用程序列表,然后只需选择 Google 地图即可。

    【讨论】:

    • 谢谢! :) 我希望谷歌地图本身能够获取用户当前位置,但没问题,我会找到一种方法来获取位置并将其传递给字符串
    • 我认为使用LocationManager 类获取当前位置信息应该不会有太大问题。绘制路线比较棘手。
    【解决方案2】:

    这会对你有所帮助。

    Intent intent = new Intent(android.content.Intent.ACTION_VIEW, 
    Uri.parse("http://maps.google.com/maps?saddr=srclatitude,srclongitude&daddr=destlat,destlong"));
    startActivity(intent);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-04-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-16
      • 1970-01-01
      • 2023-01-14
      相关资源
      最近更新 更多