【问题标题】:How to intent multiple way point in Google Maps?如何在谷歌地图中设置多个航点?
【发布时间】:2018-08-18 01:30:22
【问题描述】:

这是按钮根据 textview 地址链接到谷歌地图的代码。

button.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view){
                    String address = textViewAddress.getText().toString();
                    String addressb = textViewAddressB.getText().toString();
                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q="+address));
                    view.getContext().startActivity(intent);
                }
            });

如何在 Google 地图中意图前往多个目的地/点?因此,如果我创建了另一个 textview 地址 b,我想显示位置地址 a 到地址 b 到地址 c,如上图所示。也可能有 Waze 的意图?

【问题讨论】:

    标签: android google-maps android-studio android-intent


    【解决方案1】:

    你可以参考这个API Documentation.. 使用waypoints你可以添加多个目的地

    Uri gmmIntentUri = Uri.parse("https://www.google.com/maps/dir/?api=1&origin=18.519513,73.868315&destination=18.518496,73.879259&waypoints=18.520561,73.872435|18.519254,73.876614|18.52152,73.877327|18.52019,73.879935&travelmode=driving");
    Intent intent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
    intent.setPackage("com.google.android.apps.maps");
    try {
        startActivity(intent);
    } catch (ActivityNotFoundException ex) {
        try {
            Intent unrestrictedIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
            startActivity(unrestrictedIntent);
        } catch (ActivityNotFoundException innerEx) {
            Toast.makeText(this, "Please install a maps application", Toast.LENGTH_LONG).show();
        }
    }
    

    更新 你也可以看看这个question

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-27
      • 2020-05-03
      • 1970-01-01
      • 2020-04-22
      • 2018-03-11
      • 1970-01-01
      • 2010-12-05
      相关资源
      最近更新 更多