Android Intent to Google Maps Navigation using Google Place id (not by Coordinates or Address)

标签 android google-maps android-intent navigation

来自谷歌,
https://developers.google.com/maps/documentation/urls/android-intents#launch_turn-by-turn_navigation ,

Uri gmmIntentUri = Uri.parse("google.navigation:q=Taronga+Zoo,+Sydney+Australia");
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);

我可以在导航模式下成功打开谷歌地图,但是,由于在我的应用程序的上一页中,我使用了谷歌自动完成功能并获得了 Place .还有placeId每个地方。问题是如何使用上述逐向导航方法但使用placeId而不是地址或坐标(因为 placeId 比其他更准确)。

最佳答案

取自 docs :
如您在第一行中所见,api 端点有两个参数 - queryquery_place_id . query如果您有地点 id,则不需要准确,因为地点 id 要准确得多,所以您可以看到我只是输入了一个填充字符串(api 中仍然需要该参数)。在端点中添加您的地点 ID 并设置如图所示的 Intent ,这是在 Android 手机上打开 Google map 导航的正确 Intent 。

Uri gmmIntentUri = Uri.parse("https://www.google.com/maps/search/?api=1&query=qwerty&query_place_id=" + loc_id);
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri);
mapIntent.setPackage("com.google.android.apps.maps");
startActivity(mapIntent);

关于Android Intent to Google Maps Navigation using Google Place id (not by Coordinates or Address),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61484156/

相关文章:

Android - 记录时检查文件大小

Android - 在 Horizo​​ntalScrollView 上禁用过度滚动

javascript - 透明 div 与 Google map 上的 Google Logo 重叠

Android, Intent 不起作用?

javascript - 如何将数据从一个组件实时传递到另一个组件?

php - 将 JSON 数组发送到 MySQL

android - 如何在 android 中为 Google Place Details 结果设置语言?

android - 以编程方式启用模拟位置

java - 调用 Intent 启动 Activity 时应用程序崩溃

java - Android SpeechRecognizer 只能在应用程序的主线程中使用