【问题标题】:Show multiple markers using the geo: intent to display a map at a specified location and zoom level使用地理显示多个标记:意图在指定位置和缩放级别显示地图
【发布时间】:2020-03-11 08:57:04
【问题描述】:

我想使用地理显示一些标记:意图在指定位置和缩放级别显示地图。但我不知道如何在这里添加我的标记?有人可以帮我解决这个问题吗?

// Creates an Intent that will load a map of San Francisco
Uri gmmIntentUri = Uri.parse("geo:37.7749,-122.4194");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);

感谢您的建议。

【问题讨论】:

  • 但是在这里我需要一个 Google Api Key。我想在上面的地图上放一些标记,只放坐标。这只适用于您的解决方案和 api-Key 吗?
  • 发现了一个类似的问题here

标签: android dictionary android-intent geolocation google-maps-markers


【解决方案1】:

试试下面的例子:

Intent intent = new Intent(android.content.Intent.ACTION_VIEW,
Uri.parse("geo:37.7749,-122.4194?q=37.7749,-122.4194 (San Francisco)"));
// the following line should be used if you want use only Google maps
intent.setComponent(new ComponentName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity"));
startActivity(intent);

【讨论】:

  • 谢谢,这很好用,但它只显示 1 个标记。显示 2 或 3 个标记怎么样?您对此有解决方案吗?
  • 不,它没有解决,因为你的答案对 1 个 Marker 有好处,但我想要超过 1 个 Marker。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-01-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多