谷歌地图应用程序中未显示地理意图标签

由于我的 Google Maps 应用程序最近更新,现在版本 10.11.1,以下代码未按预期显示标签,已记录和以前工作:


  val intent = Intent(Intent.ACTION_VIEW, Uri.parse("geo:38.8951,100.0364?q=38.8951,100.0364(foo)")).setPackage("com.google.android.apps.maps")

  if (intent.resolveActivity(packageManager) == null) {

    intent.setPackage(null)

  }

  startActivity(intent)

这个版本也没有(0,0紧随其后geo:):


  val intent = Intent(Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=38.8951,100.0364(foo)")).setPackage("com.google.android.apps.maps")

  if (intent.resolveActivity(packageManager) == null) {

    intent.setPackage(null)

  }

  startActivity(intent)

官方文档中的示例代码也没有显示标签:


// Display a label at the location of Google's Sydney office

Uri gmmIntentUri = Uri.parse("geo:0,0?q=-33.8666,151.1957(Google+Sydney)");

Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);

mapIntent.setPackage("com.google.android.apps.maps");

startActivity(mapIntent);

http://img1.mukewang.com/62e128dc00016c6606521166.jpg

喵喵时光机
浏览 123回答 3
3回答

HUWWW

更新:计划在 2022 年 1 月结束之前在 v11.12 中修复。即使最新的地图更新 10.12.1 仍然没有解决方案,即使文档仍然说我应该在 Google 的问题跟踪器上创建问题,标签仍然没有显示:https ://issuetracker.google.com/issues/129726279希望我们很快就会有一些信息。

凤凰求蛊

根据谷歌,这是谷歌地图应用程序中的一个错误。它已在版本 11.12 中修复。

慕娘9325324

我认为我们在这里的做法是错误的。如果我是谷歌,我也会对允许开发人员发布带有抽象目的地标签的路线感到不安全,我相信他们永远不会打算解决这个问题。我根据谷歌的新标准推荐以下解决方案。https://developers.google.com/maps/documentation/urls/android-intents:https://www.google.com/maps/dir/?api=1&destination=LATITUDE,LONGITUDE如果您查看当今大多数应用程序,包括我构建的应用程序,这允许我们发布 LAT/LONG 供用户使用 Google 自己的内置地址值作为目标标签。要真正启动 Google 地图应用程序,只需启动一个 Web 意图,我在本例中使用应用程序上下文。    fun startGoogleMaps(context: Context, lat: Double, long: Double) {        startWebBrowser(            context,            Uri.parse("https://www.google.com/maps/dir/?api=1&destination=$lat,$long")        )    }    fun startWebBrowser(context: Context, link: Uri?) {        if (link != null) {            val webIntent = Intent(Intent.ACTION_VIEW, link).apply {                addFlags(FLAG_ACTIVITY_NEW_TASK)            }            if (webIntent.resolveActivity(context.packageManager) != null) {                context.startActivity(webIntent)            }        }    }
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java