【问题标题】:How to set the labels for source and destination in google maps programmatically in android?如何在android中以编程方式在谷歌地图中设置源和目的地的标签?
【发布时间】:2017-08-09 11:20:06
【问题描述】:

我正在使用此代码在 android 中打开 Google 地图应用。

if(source != null && destination != null) {
                    Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
                            Uri.parse("http://maps.google.com/maps?daddr="
                                    + destination.latitude + "," + destination.longitude + "(" + ADDRESS + ")"));
                    startActivity(intent);
                } else {
                    Toast.makeText(context, "Please check your internet connection and try again!!", Toast.LENGTH_LONG).show();
                }

当它进入 android 的谷歌地图应用程序时会发生什么,起初它在目标框中显示地址,在源框中显示“您的位置”,但之后,它变为“地图上的点”。有什么办法可以避免这种情况吗?还是我遗漏了什么?

谁能帮我解决这个问题?

【问题讨论】:

  • 我遇到了同样的麻烦,在目的地,一开始它会显示我们提供的确切标签,然后它会自动替换为实际地址。你解决了这个问题吗?

标签: android google-maps android-googleapiclient


【解决方案1】:

你可以设置markers在Google Maps上设置目标点和源点

String uri = String.format(Locale.ENGLISH, "geo:%f,%f?z=17&q=%f,%f", sourcelatitude,sourcelongitude,destlatitude,destlongitude);
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));

【讨论】:

  • 谢谢拉詹...我明白了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-07-13
  • 2014-07-04
  • 2019-06-04
  • 1970-01-01
相关资源
最近更新 更多