簡體   English   中英

獲取兩個地理位置之間的路線

[英]Get directions between two geopoints

我在這個問題上看到了許多答案,但是沒有一個給我正確的解決方案。 我必須明確指出,我不想在兩個地理位置之間畫一條折線。 我希望這些指示出現在textview中,例如:

1:在100碼處右轉

下面顯示了我當前擁有的代碼,但它使我上線並給了我指導,但我希望這些指導出現在textview中。 如何操縱代碼來實現這一目標?

 Intent intent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("http://maps.googleapis.com/maps/api/directions/json?origin=55.006108,-7.322766&destination=55.013534,-7.318560&sensor=false"));
 startActivity(intent);

您應該簽出google maps API,而不是嘗試解析HTML頁面。 在這里看看: https : //developers.google.com/maps/documentation/directions/

您可以這樣稱呼它: http://maps.googleapis.com/maps/api/directions/json?origin=20.344,34.34&destination=20.5666,45.345&sensor=false : http://maps.googleapis.com/maps/api/directions/json?origin=20.344,34.34&destination=20.5666,45.345&sensor=false

僅供參考,這些坐標對於路線無效,因為它們不在道路上,因此將其粘貼到API中時,您將獲得錯誤代碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM