【发布时间】:2017-04-29 02:56:59
【问题描述】:
我的问题与这个问题 (Android - How to launch Google map intent in android app with certain location, zoom level and marker) 非常相似,但接受的答案对我不起作用。它会在正确的位置和正确的缩放级别打开带有标记的地图,然后继续放大到街道级别的视图(缩放 = 16 还是 17?)。
我已经搜索过,我已经阅读了 this 文档,但找不到满足我需要的位置标记和缩放组合。
我已经尝试过一些使用 Google 地图版本的设备 8.2.0, 9.20.1, 9.36.2 & 9.42.3
这是日志打印的结果(用于意图的 Uri) 地理:39.29038619995117,-76.61219024658203?q=39.29038619995117%2C-76.61219024658203(巴尔的摩)&z=11
另一篇帖子的答案现在已经 4 岁了。地图是否已更改,以至于现在无法使用?另一个答案是否只是因为他们将缩放设置为 17 并且没有注意到它不会解决另一个缩放级别?我还缺少其他东西吗?
为了清楚地说明我的问题: 如何使用地理意图打开地图应用以显示地点标记并同时选择缩放级别?
我的代码,基于其他帖子中接受的答案。
double latitude = item.getLatitude();
double longitude = item.getLongitude();
String label = item.getName();
String uriBegin = "geo:" + latitude + "," + longitude;
String query = latitude + "," + longitude + "(" + label + ")";
String encodedQuery = Uri.encode(query);
String uriString = uriBegin + "?q=" + encodedQuery + "&z=11";
mListener.onListFragmentInteraction(uriString);
然后
public void onListFragmentInteraction(String url) {
Uri geoLocation = Uri.parse(url);
Log.d(TAG, "geo uri = " + geoLocation);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(geoLocation);
startActivity(intent);
}
【问题讨论】:
-
此功能在 Google Maps 7.x 之后被破坏。
-
@HarjotSinghOberai “在 7.x 之后中断”。谢谢,我害怕那个。你知道这是故意的还是有可能解决这个问题?您是否知道任何可以涵盖此更改的文档?
-
你仍然可以使用该功能,只是语法不同,请参阅我添加的链接。
-
我以前看过这个文件。它提供了缩放和位置标记的示例,但没有同时使用它们。你看到我遗漏的东西了吗?
标签: android google-maps android-intent