js关于根据前后两个经纬度获取转向角
a:求出前后两个坐标点的经纬度之差
b:根据atan2函数求得
具体代码如下
//求得转向角 dy,dx为前后经纬度之差
function getTheta(dy,dx) {
var theta = Math.atan2(dy, dx) * 180 / Math.PI;
if (theta < 0.0) {
theta = 360.0 - Math.abs(theta);
}
return theta;
}