怎么计算距离多少米
- 发布:2019-01-08 16:31
- 更新:2020-01-10 11:49
- 阅读:5261
uni-app map点击点标记怎么获取除markerId的其他信息
8***@qq.com (作者)
getDistance: function(lat2, lng2) {
var lat1 = this.latitude || 0;
var lng1 = this.longitude || 0;
lat2 = lat2 || 0;
lng2 = lng2 || 0;
var rad1 = lat1 Math.PI / 180.0;
var rad2 = lat2 Math.PI / 180.0;
var a = rad1 - rad2;
var b = lng1 Math.PI / 180.0 - lng2 Math.PI / 180.0;
var r = 6378137;
this.distance = (r 2 Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(rad1) Math.cos(rad2) Math
.pow(Math
.sin(b / 2), 2)))).toFixed(0)
},