위도와 경도의 두 좌표 사이의 각도를 아래 코드와 같이 계산했습니다. 각도를 라디안 단위로 3, 각도 단위로 193을 반환합니다. 이 각도에 따라지도에 화살표 표식을 표시하고 싶습니다.이 각도를 기준으로 이동 한 객체 방향을 표시하는 방법은 무엇입니까?각도로 계산 된 각도를 기반으로지도에 방향을 표시하는 방법
public static double getAngle(double lat1, double lon1, double lat2, double lon2)
{
//Formulas
//θ = atan2( sin(Δlong).cos(lat2),cos(lat1).sin(lat2) − sin(lat1).cos(lat2).cos(Δlong))
// Δlong = long2 - long1
Log.i("angle", "Inside getAngle");
double latitude1 = Math.toRadians(lat1);
double longitude1 = Math.toRadians(lon1);
double latitude2 = Math.toRadians(lat2);
double longitude2 = Math.toRadians(lon2);
double dlong = Math.toRadians(longitude2-longitude1);
double y = Math.sin(dlong) * Math.cos(latitude2);
double x = Math.cos(latitude1)*Math.sin(latitude2) - Math.sin(latitude1)*Math.cos(latitude2)*Math.cos(dlong);
double angle= Math.atan2(y, x);
if (angle < 0)
angle = Math.abs(angle);
else
angle = 2*Math.PI - angle;
Log.i("angle", String.valueOf(angle)+" in radians");
angle=Math.toDegrees(angle);
Log.i("angle", String.valueOf(angle)+" in degrees");
return angle;
}
이렇게 해보십시오. Uri.parse ("http://maps.google.com/maps?f=d&daddr=51.448,-0.972")); 두 점 사이의 방향을 찾으려면 .. – Janmejoy
아니요. Google Directions API 및 길 찾기를 사용하고 싶지 않습니다. 경로 위치가 이미 있습니다. 화살표로 폴리 라인으로 연결하고 싶습니다. – Ramprasad