直接上代码
function destination(lng,lat, heading, distance) { //计算扇形的眯点坐标 heading = (heading + 360) % 360; var rad = Math.PI / 180, radInv = 180 / Math.PI, R = 6378137, // approximation of Earth‘s radius lon1 = lng * rad, lat1 = lat * rad, rheading = heading * rad, sinLat1 = Math.sin(lat1), cosLat1 = Math.cos(lat1), cosDistR = Math.cos(distance / R), sinDistR = Math.sin(distance / R), lat2 = Math.asin( sinLat1 * cosDistR + cosLat1 * sinDistR * Math.cos(rheading) ), lon2 = lon1 + Math.atan2( Math.sin(rheading) * sinDistR * cosLat1, cosDistR - sinLat1 * Math.sin(lat2) ); lon2 = lon2 * radInv; lon2 = lon2 > 180 ? lon2 - 360 : lon2 < -180 ? lon2 + 360 : lon2; lat2 = lat2 * radInv return [lon2,lat2] }
封装好的方法,之后调用方法即可
var new = destination(lng,lat, heading, distance)//经度,纬度,方位角,距离
console.log(new)
原文:https://www.cnblogs.com/wuzhaoyu/p/14792493.html