2013-07-10 3 views
0

현재 위치에서 특정 위치 (var : end)까지 내 경로를 계산하려고합니다. 현재 위치에서 LatLng을 가져 오려면 어떻게해야하나요? GMAPS API V3에서 현재 Lat Lng 위치를 얻는 방법은 무엇입니까?

들으

가 여기 내 코드 : 당신은 (위치 호출 할 수 있습니다)은 위치 개체가있는 경우

function calcRoute() { 
var start = "How to get this LatLng ?"; 
var end = new google.maps.LatLng(-6.28529,106.871542); 
var request = { 
    origin:start, 
    destination:end, 
    travelMode: google.maps.TravelMode.WALKING 
}; 

directionsService.route(request, function(result, status) { 
    if (status == google.maps.DirectionsStatus.OK) { 
     directionsDisplay.setDirections(result); 
     } 
    }); 
} 
+0

휴대 전화에서 gps를 사용해야합니다. http://developer.android.com/guide/topics/location/strategies.html – Scott

+0

기기 위치는 알았지 만 위도와 경도가 필요합니까? 어떻게? – user2565280

답변

0

, 당신이 할 필요가 LatLng mLatLng = new LatLng(location.getLatitude(), location.getLongitude()) 그리고 당신은 위도 경도 개체를해야합니다. location.getLatitude()은도 단위의 위도에 해당하는 double을 반환하고 location.getLongitude()은 동일하지만 경도를 반환합니다. 자세한 내용은 설명서를 참조하십시오. http://developer.android.com/reference/android/location/Location.html

+0

와우 :) 고맙습니다. – user2565280

관련 문제