2017-03-08 2 views
1

지도에 여러 위치를 표시하는 Android 앱이 있습니다. 위치를 클릭하면 위도가 긴 위치 및 기기 위치의 위도를 Google지도 앱에 전달하여 둘 사이에 경로 정보를 표시 할 수 있습니다.Android, Google지도 앱에 긴 긴 경로 정보 전달 방법

이것이 가능합니까? 그렇다면 어떻게? 감사합니다. .

답변

1

이 함께 시도 할 수 있습니다 :

googleMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() 
{ 
    @Override 
    public void onMapClick(LatLng latLng) 
    { 
     String url = "http://maps.google.com/maps?daddr=" + latLng.latitude + "," + latLng.longitude;   
     Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); 
     startActivity(intent); 
    } 
}); 
1

예, 당신은지도에 위도와 LNG를 전달할 수 있습니다, 그 장소에 표시 방향은 안드로이드 의도를 사용하여.

길 찾기는 항상 사용자의 현재 위치에서 제공됩니다.

다음 쿼리를 사용하면 도움이됩니다. 당신은 대상 위도와 여기에 경도 전달할 수 있습니다

google.navigation:q=latitude,longitude 

를 사용하여 위의 같은 : 여기

Uri gmmIntentUri = Uri.parse("google.navigation:q=latitude,longitude"); 
Intent mapIntent = new Intent(Intent.ACTION_VIEW, gmmIntentUri); 
mapIntent.setPackage("com.google.android.apps.maps"); 
startActivity(mapIntent); 

추가 정보 : https://developers.google.com/maps/documentation/urls/android-intents 구글 방법으로 권장 2017으로

3

Google지도의 URL입니다 :

https://developers.google.com/maps/documentation/urls/guide#directions-action

는 CA n 문서에 따라 Google 길 찾기를위한 범용 범용 범용 URL을 만들고 의도에 따라 URL을 사용하십시오. 예를 들어, URL이 도움이 뭔가

googleMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() 
{ 
    @Override 
    public void onMapClick(LatLng latLng) 
    { 
     String url = "https://www.google.com/maps/dir/?api=1&destination=" + latLng.latitude + "," + latLng.longitude + "&travelmode=driving";   
     Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); 
     startActivity(intent); 
    } 
}); 

https://www.google.com/maps/dir/?api=1&destination=60.626200,16.776800&travelmode=driving

같은 희망 수 있습니다!