export function computedSpace(lng1, lat1, lng2, lat2) {
const radLat1 = (Number(lat1) * Math.PI) / 180.0;
const radLat2 = (Number(lat2) * Math.PI) / 180.0;
const a = radLat1 - radLat2;
const b = (Number(lng1) * Math.PI) / 180.0 - (Number(lng2) * Math.PI) / 180.0;
// eslint-disable-next-line no-restricted-properties
let s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
s *= 6378.137;
s = Math.round(s * 10000) / 10000;
return s; // 单位千米
}
GPS:根据起终点/两地之间的经纬度,来计算两点之间的距离
最新推荐文章于 2023-04-08 14:32:22 发布