计算 Polygan 数组中的中心点
function calculateCenter(arr){
let total = arr.length;
let [x,y,z]=[0,0,0];
arr.forEach(position=>{
let lng = position[0] * Math.PI / 180;
let lat = position[1] * Math.PI / 180;
x += Math.cos(lat) * Math.cos(lng);
y += Math.cos(lat) * Math.sin(lng);
z += Math.sin(lat);
});
x = x/total;
y = y/total;
z = z/total;
let longitude = Math.atan2(y,x);
let latitude = Math.atan2(z,Math.sqrt(x*x + y*y));
return [longitude*180/Math.PI,latitude*180/Math.PI];
}