【发布时间】:2020-11-18 13:11:57
【问题描述】:
谷歌地图开发人员有没有办法或是否有一个框架,用于使用 kotlin 在 android stuio 谷歌地图中从您的位置到您尝试去的地理位置。我正在寻找一些解决方案,但我似乎很难找到即使在谷歌地图开发人员中阅读也没有。
【问题讨论】:
标签: android-studio kotlin google-maps-android-api-2
谷歌地图开发人员有没有办法或是否有一个框架,用于使用 kotlin 在 android stuio 谷歌地图中从您的位置到您尝试去的地理位置。我正在寻找一些解决方案,但我似乎很难找到即使在谷歌地图开发人员中阅读也没有。
【问题讨论】:
标签: android-studio kotlin google-maps-android-api-2
您可以使用显式 Intent 启动 Google 地图应用,并将目的地坐标作为 Intent 参数。
// Create a Uri from an intent string. Use the result to create an Intent.
val googleMapsIntentUri = Uri.parse(
"google.navigation:q=$destination_latitude,$destination_longitude"
)
// Create an Intent from googleMapsIntentUri. Set the action to ACTION_VIEW
val mapIntent = Intent(Intent.ACTION_VIEW, googleMapsIntentUri)
// Make the Intent explicit by setting the Google Maps package
mapIntent.setPackage("com.google.android.apps.maps")
// Attempt to start an activity that can handle the Intent
startActivity(mapIntent)
【讨论】:
"https://www.google.com/maps/dir/?api=1&your_parameters",而不是字符串"google.navigation:q=$destination_latitude,$destination_longitude"。