0
Google지도 (안드로이드)에 이 있으며, 마커를 bearing
및 distance
이라는 새로운 위치로 이동하고 싶습니다.실제 거리를 Google지도 거리로 변환
//lat, lng in degrees. Bearing in degrees. Distance in Km
private LatLng newPostion(Double lat,Double lng,Double bearing,Double distance) {
Double R = 6371; // Earth Radius in Km
Double lat2 = Math.asin(Math.sin(Math.PI/180 * lat) * Math.cos(distance/R) + Math.cos(Math.PI/180 * lat) * Math.sin(distance/R) * Math.cos(Math.PI/180 * bearing));
Double lon2 = Math.PI/180 * lng + Math.atan2(Math.sin(Math.PI/180 * bearing) * Math.sin(distance/R) * Math.cos(Math.PI/180 * lat), Math.cos(distance/R) - Math.sin(Math.PI/180 * lat) * Math.sin(lat2));
Double newLat = 180/Math.PI * lat2;
Double newLng = 180/Math.PI * lon2;
LatLng newLatLng = new LatLng(newLat, newLng);
return newLatLng;
}
LatLng newPos = newPostion(myMark.getPosition().latitude,myMark.getPosition().longitude, 90.0,3000.0);
거리는 속도 * 시간으로 계산됩니다.
distance = speed * time
마커가 자동차를 나타내며 자동차가 100km/h로 이동한다고 가정하면 5 초마다 마커를 업데이트해야합니다.
distance = 100 * (5/60)
하지만 구글지도가 축소되기 때문에 문제는 구글지도에서 distance
을 보이고있다. 위에 계산 된 거리를 사용하여 마커를 이동하면 마커가 훨씬 더 이동합니다.
실제 거리를 Google지도 거리로 변환 할 수있는 사람이 있습니까?
wohaa. 무리 감사! :) –