![](/img/trans.png)
[英]I want to make an Android app with a map that provides directions, but not Google Maps
[英]Using Google Maps Directions in Android App
我正在尝试使用我的 web 应用程序 www.scroutenise.com 开发一个 Android 应用程序到go ,所以我制作了一个后端 API 来模仿返回的 Javascript 应用程序的行为
两者都采用谷歌地图 API 提供的相同格式。太棒了 - 使用 JS 我可以轻松地在谷歌 Map 上呈现它。
到目前为止,在我的应用程序中,我已成功与 API 通信并获得完整结果 - 请记住 API 是 WebSockets API,因此没有 URL - 我有一个 Google 882883644450788 显示。
我唯一找不到文档或教程的是如何在 map 上显示方向。我确信我可以弄清楚如何放置标记,但方向方面是我的应用程序的一个非常重要的方面。 有可能吗? Google 是否必须遵守一些条款和条件来阻止人们制作与路线相关的应用程序?
感谢阅读,希望有人能提供帮助:)
在 Android 中,您可以通过使用 Intent 指定行车路线:
String geoUriString = "http://maps.google.com/maps?" +
"saddr=" + srcLat + "," + srcLng + "&daddr=" + dstLat + "," + dstLng;
Intent mapCall = new Intent(Intent.ACTION_VIEW, Uri.parse(geoUriString));
然后根据您设备上安装的应用程序(导航、地图等),用户将能够从这些应用程序之一接收方向。
我不明白你在这里的指示是什么意思,但你可以使用这篇文章中描述的方式绘制路径。
http://csie-tw.blogspot.com/2009/06/android-driving-direction-route-path.html
String uri= "https://www.google.com/maps/dir/" +
fromLat + "," + fromLng + "/" + toLat + "," + toLng;
Intent mapCall = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
或者只有“to”的位置,用户必须打开 GPS:
String uri= "https://www.google.com/maps/dir//" + toLat + "," + toLng;
Intent mapCall = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.