var EARTH_RADIUS = 6378137.0;//地球赤道半径(单位:m。6378137m是1980年的标准,比1975年的标准6378140少3m)
/// <summary>
/// 弧度转换为角度数公式
/// </summary>
/// <param name="d"></param>
/// <returns></returns>
function degrees(d) {
return d * (180 / Math.PI);
}
/// <summary>
/// 以一个经纬度为中心计算出四个顶点
/// </summary>
/// <param name="Degree1">中心点</param>
/// <param name="distance">半径(米)</param>
/// <returns></returns>
function GetDegreeCoordinates(Degree1, distance) {
var dlng = 2 * Math.asin(Math.sin(distance / (2 * EARTH_RADIUS)) / Math.cos(Degree1.X));
dlng = degrees(dlng);//一定转换成角度数
var dlat = distance / EARTH_RADIUS;
dlat = degrees(dlat);//一定转换成角度数
let data = [
[xx(Degree1.X + dlng), xx(Degree1.Y + dlat)],//right-top
[xx(Degree1.X - dlng), xx(Degree1.Y + dlat)],//left-top
[xx(Degree1.X - dlng), xx(Degree1.Y - dlat)],//left-bottom
[xx(Degree1.X + dlng), xx(Degree1.Y - dlat)]] //right-bottom
return data;
}
function xx(num){
num = num.toString();
let xxx = num.split(".");
xxx[1] = xxx[1].substr(0,6);
return xxx[0]+'.'+xxx[1];
}
网友评论