@tuoyuan/map-adapter-lib
Version:
地图适配器库
12 lines (11 loc) • 398 B
JavaScript
function n(a) {
return a * Math.PI / 180;
}
function M(a, o) {
const s = n(a.latitude), r = n(a.longitude), e = n(o.latitude), c = n(o.longitude), d = s - e, h = r - c;
let t = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(d / 2), 2) + Math.cos(s) * Math.cos(e) * Math.pow(Math.sin(h / 2), 2)));
return t = t * 6378.137, t = Math.round(t * 1e4) / 1e4, t * 1e3;
}
export {
M as getDistance
};