【问题标题】:How to add marker to a specific location in Google Maps in Android Studio?如何在 Android Studio 的 Google 地图中将标记添加到特定位置?
【发布时间】:2020-11-21 13:43:48
【问题描述】:

我创建了一个按钮,可将用户带到 Google 地图上的特定位置。这是sn-p:

String uri = String.format(Locale.ENGLISH, "geo:%f,%f", latitude, longitude);
                        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
                        context.startActivity(intent);

但是,地图只是缩放到特定位置,而没有在我放置的坐标上添加标记。有人可以帮帮我吗?

谢谢。

【问题讨论】:

标签: android location marker


【解决方案1】:

这对我有用(“hellothere”是您可以替换或删除的标签):

String uri = String.format(Locale.ENGLISH, "geo:0,0?q=%f,%f(hellothere)",latitude,longitude);

更新:在提供位置查询时,geo: 参数可以是 0,0。

(在测试时,您可能希望每次测试都关闭地图应用,尤其是在不移动标记的情况下。)

【讨论】:

  • 谢谢!标记现在可见。但是,我看不到您在解决方案的括号中提到的“你好”标签。
  • 要明确一点 - 'hellothere' 中没有空格,所以它不需要 urlencoding - 或者干脆做 'hello+there'。
猜你喜欢
  • 2021-09-03
  • 2011-04-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-09-13
  • 1970-01-01
  • 2018-10-21
相关资源
最近更新 更多