gpt4 book ai didi

android - 使用 native Google map 的 PhoneGap 方向

转载 作者:行者123 更新时间:2023-11-29 00:25:54 25 4
gpt4 key购买 nike

我有一个包含按钮的应用程序,该按钮应向用户显示前往本地企业的路线。我希望使用 Google map 提供方向,包括从用户当前位置开始的逐步道路方向。

我希望本地 Google map 应用程序能够处理方向,但是当我尝试 https://maps.google.com/maps?q=... 的 href,Google map 在用户的网络浏览器中打开,而不是在他们的 Google map 应用中。

这张基于网络的 map 没有提供我想要的分步指导 - 它只提供了从 A 点到 B 点的俯 View 。

我也试过

<a href="geo:38.897096,-77.036545">businesname</a>

<a href="geo:someAddressHere">businessname</a>

这些 href确实启动了原生 Google map 应用,但未显示分步说明。

总结:我如何显示 Google map View 以提供逐步指导(最好使用 native 应用程序)。

最佳答案

您要找的是 intent .这是一个将一些信息传递给其他应用程序并可以启动它的命令。

我要做的是在您的代码中添加一个方法,当用户触摸按钮时调用该方法。这种方法类似于:

//Pass the link to the itinerary you want
void launchGMaps(String link) {

//Pass the link and the instruction to show something to an Intent
Intent myIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse(link));
//Give the name of the app to start and the activity to start in this app.
myIntent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
//Gooooooooooo !
startActivity(myIntent);
}

希望对您有所帮助。

F

关于android - 使用 native Google map 的 PhoneGap 方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19506787/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com