来自谷歌,
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 端点有两个参数 - query
和 query_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/