티스토리 뷰
두 마커사이의 거리나 어느 특정한 지점간의 거리를 구할때의 방법입니다.
public double getDistance(LatLng LatLng1, LatLng LatLng2) {
double distance = 0;
Location locationA = new Location("A");
locationA.setLatitude(LatLng1.latitude);
locationA.setLongitude(LatLng1.longitude);
Location locationB = new Location("B");
locationB.setLatitude(LatLng2.latitude);
locationB.setLongitude(LatLng2.longitude);
distance = locationA.distanceTo(locationB);
return distance;
}
먼저 첫 번째 지점의 Latitude와 Longitude 값과 두 번째 지점의 Latitude, Longitude 값을 알아야합니다.
가져온 값을 바탕으로 locationA 와 locationB 2개의 객체를 생성 해줍니다.
그리고 distanceTo라는 함수를 이용해서 2 location간의 일직선 거리를 구할 수 있습니다.
'개발 > Android' 카테고리의 다른 글
[Android] / 안드로이드 / Marker Animation / 마커에 깜빡이는 애니메이션 효과주기 (0) | 2016.11.15 |
---|---|
[Android] / 안드로이드 / SoundPool 사용법 / How can Use SoundPool / (0) | 2016.11.09 |
[Android] / 안드로이드 / OS version check / OS버전 체크 / OS별로 분기 (0) | 2016.10.27 |
[Android] / 안드로이드 / textView 부분색상 바꾸기 / text color / 텍스트 부분색 바꾸기 (1) | 2016.10.19 |
[Android] / 안드로이드 / HttpPost 한글 깨짐 현상 (0) | 2016.10.12 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- 개발자
- development
- Android
- 마커
- imageButton
- play service
- jQuery
- 코드삽입
- GOOGLE PLAY
- 코드 넣기
- JavaScript
- 안드로이드
- 앱
- 개발
- SyntaxHighlighter
- 소스코드
- Android Studio
- imagesize
- dependencies
- Marker
- 코드
- zindex
- 구글맵
- 깜빡임
- comma
- GoogleAnalytics
- googlemap
- Google Analytics
- titlebat
- Google Map
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 31 |
글 보관함