首页 > 解决方案 > 如何在 Android Studio 的 Google 地图中将标记添加到特定位置?

问题描述

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

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

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

谢谢你。

标签: androidlocationmarker

解决方案


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

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

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

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


推荐阅读