[英]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.