반응형
* 코드 참고
https://webnautes.tistory.com/1011
https://jinseongsoft.tistory.com/23
- 수정한 부분
private LatLng startLatLng = new LatLng(0, 0);
private LatLng endLatLng = new LatLng(0, 0);
List<Polyline>polylines =new ArrayList<>();
LocationCallback locationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
super.onLocationResult(locationResult);
List<Location> locationList = locationResult.getLocations();
if (locationList.size() > 0) {
location = locationList.get(locationList.size() - 1);
//location = locationList.get(0);
double latitude =location.getLatitude();
double longtitude=location.getLongitude();
if(startLatLng.latitude==0&&startLatLng.longitude==0){
startLatLng=new LatLng(latitude,longtitude);
}
currentPosition
= new LatLng(latitude, longtitude);
String markerTitle = getCurrentAddress(currentPosition);
String markerSnippet = "위도:" + String.valueOf(latitude)
+ " 경도:" + String.valueOf(longtitude);
Log.d(TAG, "onLocationResult : " + markerSnippet);
//현재 위치에 마커 생성하고 이동
setCurrentLocation(location, markerTitle, markerSnippet);
mCurrentLocatiion = location;
endLatLng = new LatLng(latitude, longtitude);
drawPath();
startLatLng = new LatLng(latitude, longtitude);
}
}
};
반응형
'프로그래밍 > App 개발' 카테고리의 다른 글
[android] 앱 종료 시 블루투스 해제되는 issue (1) | 2020.08.06 |
---|---|
[android] 안드로이드 wav 레코딩 (20.06.28 깨달은점) (0) | 2020.08.06 |
[android] MPAndroidChart를 활용한 실시간 차트 그리기 (0) | 2020.08.06 |
[android] MVVM의 편리함 (20.05.28 깨달은 점) (0) | 2020.08.06 |
[android] FCM 푸시 (node.js, android) (0) | 2020.08.06 |