반응형
* 코드 참고
https://webnautes.tistory.com/1011
Android Google Map에 현재 위치 표시하기( GoogleApiClient, FusedLocationApi 사용)
GoogleApiClient와 FusedLocationApi를 사용하여 구글맵에 현재 위치를 표시하는 예제입니다. 최종 업데이트 - 2017. 11.27 Deprecated된 FusedLocationApi를 대체하는 FusedLocationProviderClient를 사용하도..
webnautes.tistory.com
https://jinseongsoft.tistory.com/23
(Android) Google Map 이동한 거리 선(polyline) 으로 그리기
Android Google Map Polyline Google Map 라이브러리를 사용하여 지도 관련 프로젝트를 진행하고 있습니다. GPS를 통해 걸음을 체크하는 서비스 걸음 시작 버튼을 누른 후부터 특정 주기로 GPS를 기록하여 �
jinseongsoft.tistory.com
- 수정한 부분
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 |