参数
[[113.049055,23.273062],[113.922468,23.605693],[114.230085,22.615453],[112.697493,22.954773],[112.851301,23.484833]]
calculateCenter(lnglatarr) {
var total = lnglatarr.length;
var X = 0,
Y = 0,
Z = 0;
lnglatarr.map((item) => {
var lng = (item[0] * Math.PI) / 180;
var lat = (item[1] * Math.PI) / 180;
var x, y, z;
x = Math.cos(lat) * Math.cos(lng);
y = Math.cos(lat) * Math.sin(lng);
z = Math.sin(lat);
X += x;
Y += y;
Z += z;
});
X = X / total;
Y = Y / total;
Z = Z / total;
var Lng = Math.atan2(Y, X);
var Hyp = Math.sqrt(X * X + Y * Y);
var Lat = Math.atan2(Z, Hyp);
re
|