计算经纬度 2点之间的距离
Posted 沿着路走到底
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了计算经纬度 2点之间的距离相关的知识,希望对你有一定的参考价值。
rad(d) {
return d * Math.PI / 180.0
},
getDistance: function (lat1, lng1, lat2, lng2) {
var radLat1 = this.rad(lat1);
var radLat2 = this.rad(lat2);
var a = radLat1 - radLat2;
var b = this.rad(lng1) - this.rad(lng2);
var 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 = s * 6378.137; // EARTH_RADIUS;
s = Math.round(s * 10000) / 10;
return s;
},
以上是关于计算经纬度 2点之间的距离的主要内容,如果未能解决你的问题,请参考以下文章