[英]Geo Intent Label not showing in Google Maps App
Since my Google Maps app updated recently, now version 10.11.1 , the following code does not show the label as expected, documented , and previously working:由于我的 Google 地图应用程序最近更新,现在是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)
And neither does this version (with 0,0
immediately after geo:
):这个版本也没有(在
geo:
之后立即有0,0
):
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)
Neither does the example code in the official documentation show a label: 官方文档中的示例代码也没有显示标签:
// 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);
No solution still even with latest map update 10.12.1 the label still does not show even if the documentation still says it should I've created an issue on Google's Issue tracker: https://issuetracker.google.com/issues/129726279即使最新的地图更新 10.12.1 仍然没有解决方案,即使文档仍然说我应该在 Google 的问题跟踪器上创建问题,标签仍然不显示: https : //issuetracker.google.com/issues/129726279
hopefully we'll have some information shortly.希望我们很快就会得到一些信息。
Per Google , it's a bug in the Google Maps app. 根据 Google ,这是 Google Maps 应用程序中的一个错误。 It's fixed in version 11.12.
它已在 11.12 版中修复。
I think we are going about it the wrong way here.我认为我们在这里以错误的方式进行。 If I was Google, I would also feel insecure about allowing developers to post directions with an abstract destination label, I am sure they never plan to fix this.
如果我是谷歌,我也会对允许开发人员发布带有抽象目的地标签的路线感到不安,我相信他们从来没有打算解决这个问题。
I recommend the following solution according to Google's new standards.我根据谷歌的新标准推荐以下解决方案。 https://developers.google.com/maps/documentation/urls/android-intents :
https://developers.google.com/maps/documentation/urls/android-intents :
https://www.google.com/maps/dir/?api=1&destination=LATITUDE,LONGITUDE
If you look at most apps these days, including the ones I have built, this allows us to post a LAT/LONG for the user to go to with Google's own Address values built in as the destination label.如果您查看这些天的大多数应用程序,包括我构建的应用程序,这允许我们发布 LAT/LONG 供用户使用 Google 自己的内置地址值作为目标标签访问。
To actually launch the Google Maps application, simply launch a web intent, I use the application context in this case.要实际启动 Google Maps 应用程序,只需启动一个 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)
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.