android - 如何在 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);
但是,地图只是缩放到特定位置,而没有在我放置的坐标上添加标记。有人可以帮帮我吗?
谢谢你。
解决方案
这对我有用(“hellothere”是一个可以替换或删除的标签):
String uri = String.format(Locale.ENGLISH, "geo:0,0?q=%f,%f(hellothere)",latitude,longitude);
更新:提供位置查询时,geo: 参数可以是 0,0。
(在测试时,您可能希望每次测试都关闭 Map 应用程序,尤其是在不移动标记的情况下。)
推荐阅读
- css - 如何使用 CSS 更改材料图标 angular 7 的字体系列
- javascript - 尝试在 Node.js 中提供 png:无法读取未定义的属性“结束”
- arrays - 3d 矩阵的复杂重塑
- swiftui - 访问扩展中的环境变量
- unity3d - 在多人游戏中计算死亡人数
- java - 日期格式:我想根据格式“0001-01-01-00.00.00.000000”的时间戳获取以下日期格式 25/11/1990 14:35
- reactjs - 如何从 Panresponder onMove 回调(React Native)中的滚动视图中获取我的视图索引
- c++ - 什么是 __lll_lock_wait_private 以及调用 malloc_consolidate 时会导致挂起的原因是什么?
- html - Kendo Angular Donut Chart 样式似乎随机切换
- ruby-on-rails - Cloudflare 源 IP 和机架攻击轨道