2017-05-04 4 views
-3

사용자의 경로를 기록해야하는 앱을 만들고 있습니다. 나는 출발점을 기록하는 방법 만 알고 있지만 나머지는 어떻게해야할지 모른다. 도와주세요.사용자가 걷는 동안 경로를 기록하는 방법

내 일 :

ArrayList<LatLng> routeLatlng = new ArrayList<LatLng>();  
Location currentLocation = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient); 

routeLatlng.add(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude())); 
+1

5 초마다 똑같은 작업을 반복하여 새 위치를 가져와 순서대로 배열에 저장하면 바로 사용할 수 있습니다. –

+0

@SrihariKaranth가 말했듯이. 그러나 사용자가 차이를 만들 정도로 멀리 이동할 때마다 또는 충분한 시간이 경과 할 때마다 상기 메소드를 호출 할 위치 수신기를 사용하십시오. – Doomsknight

답변

2

봅니다 경로를 기록하는 onLocationChanged 방법을 덮어 쓸 수 있습니다. 사용자의 현재 위치가 변경되면 응답합니다.

@Override 
public void onLocationChanged(Location currentLocation) { 
    routeLatlng.add(new LatLng(currentLocation.getLatitude(), currentLocation.getLongitude())); 
} 
+0

감사합니다. 그것은 작동합니다. –