JS根据一个经纬度及距离角度,算出另外一个经纬度
var mapnumberutil = {};
/**
* 根据一个经纬度及距离角度,算出另外一个经纬度
* @param {*} lng 经度 113.3960698
* @param {*} lat 纬度 22.941386
* @param {*} brng 方位角 45 ---- 正北方:000°或360° 正东方:090° 正南方:180° 正西方:270°
* @param {*} dist 90000距离(米)
*
*/
mapnumberutil.getlonandlat = function (lng,lat,brng,dist){
//大地坐标系资料wgs-84 长半径a=6378137 短半径b=6356752.3142 扁率f=1/298.2572236
var a=6378137;
var b=6356752.3142;
var f=1/298.257223563;
var lon1 = lng*1;
var lat1 = lat*1;
var s = dist;
var alpha1 = mapnumberutil.rad(brng);
var sinalpha1 = math.sin(alpha1);
var cosalpha1 = math.cos(alpha1);
var tanu1 = (1-f) * math.tan(mapnumberutil.rad(lat1));
var cosu1 = 1 / math.sqrt((1 + tanu1*tanu1)), sinu1 = tanu1*cosu1;
var sigma1 = math.atan2(tanu1, cosalpha1);
var sinalpha = cosu1 * sinalpha1;
var cossqalpha = 1 - sinalpha*sinalpha;
var usq = cossqalpha * (a*a - b*b) / (b*b);
var a = 1 + usq/16384*(4096+usq*(-768+usq*(320-175*usq)));
var b = usq/1024 * (256+usq*(-128+usq*(74-47*usq)));
var sigma = s / (b*a), sigmap = 2*math.pi;
while (math.abs(sigma-sigmap) > 1e-12) {
var cos2sigmam = math.cos(2*sigma1 + sigma);
var sinsigma = math.sin(sigma);
var cossigma = math.cos(sigma);
var deltasigma = b*sinsigma*(cos2sigmam+b/4*(cossigma*(-1+2*cos2sigmam*cos2sigmam)-
b/6*cos2sigmam*(-3+4*sinsigma*sinsigma)*(-3+4*cos2sigmam*cos2sigmam)));
sigmap = sigma;
sigma = s / (b*a) + deltasigma;
}
var tmp = sinu1*sinsigma - cosu1*cossigma*cosalpha1;
var lat2 = math.atan2(sinu1*cossigma + cosu1*sinsigma*cosalpha1,
(1-f)*math.sqrt(sinalpha*sinalpha + tmp*tmp));
var lambda = math.atan2(sinsigma*sinalpha1, cosu1*cossigma - sinu1*sinsigma*cosalpha1);
var c = f/16*cossqalpha*(4+f*(4-3*cossqalpha));
var l = lambda - (1-c) * f * sinalpha *
(sigma + c*sinsigma*(cos2sigmam+c*cossigma*(-1+2*cos2sigmam*cos2sigmam)));
var revaz = math.atan2(sinalpha, -tmp); // final bearing
var lnglatobj = {lng:lon1+mapnumberutil.deg(l),lat:mapnumberutil.deg(lat2)}
return lnglatobj;
}