-2
我有兩點的緯度和longutude。我想通過按鈕點擊從我的應用打開谷歌地圖來顯示他們之間的路線。如何做?如何顯示地圖上兩點之間的距離
我有兩點的緯度和longutude。我想通過按鈕點擊從我的應用打開谷歌地圖來顯示他們之間的路線。如何做?如何顯示地圖上兩點之間的距離
使用下面的獲得在谷歌地圖上顯示的路線代碼...
final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("
http://maps.google.com/maps?" +"saddr=" + sourcelatLng + "&daddr=" + destlatlng;
intent.setClassName("com.google.android.apps.maps", "com.google.android.maps.MapsActivity");
startActivity(intent);
如果你想打開地圖應用從源到目的地的路線,你只需要啓動以下目的的活動。
Uri routeUri = Uri.parse("http://maps.google.com/maps?saddr=your-lat-1,your-lng-1&daddr=your-lat-2,your-lng-2");
Intent intent = new Intent(android.content.Intent.ACTION_VIEW, routeUri);
startActivity(intent);
用您的緯度和經度替換您的lat/lng-1/2。
到目前爲止你做了什麼? –
MapView似乎不提供簡單的api方法來做到這一點,但您可以通過map api獲取路線點:https://stackoverflow.com/questions/13911279/simplest-way-to-draw-a-route-on-mapview – smora
[如何在Google地圖上繪製2點之間的路徑]的可能重複(https://stackoverflow.com/questions/21154758/how-to-draw-path-between-2-points-on-google-map) –