微信小程序-计算二者之间的距离直线-微信有没有测量距离的小程序-微信小程序ibeacon
onLoad:function(options){
2.this.distance(la1,lo1,la2,lo2);//二者之间的距离
3.//修改distance这里面的四个参数la1为a地点的纬度,lo1为a地点的纬度,la2为b地点的纬度,lo2为b地点的纬度
4.}
5.distance:function(la1,lo1,la2,lo2){//计算距离km
6.varLa1la1*Math.PI/180.0;
7.varLa2la2*Math.PI/180.0;
8.varLa3La1-La2;
9.varLb3lo1*Math.PI/180.0-lo2*Math.PI/180.0;
10.vars2*Math.asin(Math.sqrt(Math.pow(Math.sin(La3/2),2)+Math.cos(La1)*Math.cos(La2)*Math.pow(Math.sin(Lb3/2),2)));
11.ss*6378.137;//地球半径
12.sMath.round(s*10000)/10000;
13.returns
14.//console.log("计算结果:"+s+"km");
15.},
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。

