【问题标题】:How i can set My start point with my end point in google Maps By Intent?如何在 Google Maps By Intent 中设置我的起点和终点?
【发布时间】:2017-07-06 08:03:40
【问题描述】:

我可以在这里设置我的终点。如何设置起点?

Uri gmmIntentUri = Uri.parse("google.navigation:q=Taronga+Zoo,+Sydney+Australia");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);

【问题讨论】:

    标签: android google-maps android-studio google-maps-markers google-maps-urls


    【解决方案1】:

    Google 推出新 API:Google Maps URLs

    https://developers.google.com/maps/documentation/urls/guide

    这个API允许创建

    一个通用的跨平台 URL,用于启动 Google 地图并执行搜索、获取路线和导航,以及显示地图视图和全景图像。

    从现在开始你可以使用类似的东西

    Uri gmmIntentUri = Uri.parse("https://www.google.com/maps/dir/?api=1&origin=Space+Needle+Seattle+WA&destination=Pike+Place+Market+Seattle+WA&dir_action=navigate");
    Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
    mapIntent.setPackage("com.google.android.apps.maps");
    startActivity(mapIntent);
    

    希望这会有所帮助!

    【讨论】:

      【解决方案2】:

      在sn-p下面使用:

      String uri = "http://maps.google.com/maps?hl=en&saddr=" + currentlatLng.latitude + "," + currentlatLng.longitude + "&daddr=" + destination.latitude + "," + destination.longitude+ "&mode=driving";
                      Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
                      intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
                      startActivityForResult(intent, Constants.REQUEST_OPEN_GOOGLE_MAP);
      

      【讨论】:

      • Google 建议使用 Google 地图网址:developers.google.com/maps/documentation/android-api/intents
      • @xomena 在我的场景中我必须使用它来打开带有 lat lng 的谷歌地图应用程序。
      • 完美,新的和受 Google 祝福的方式是 Google Maps URLs。查看文档,这些 URL 是跨平台的,因此本机应用程序可以轻松理解它们。相同的 URL 将适用于 Android、iOS 或桌面浏览器。
      • @xomena 好的,我会检查的,
      猜你喜欢
      • 2021-07-20
      • 1970-01-01
      • 2016-07-24
      • 1970-01-01
      • 1970-01-01
      • 2013-03-30
      • 2016-09-23
      • 2016-11-10
      相关资源
      最近更新 更多