GetDistance:function(lat1, lng1, lat2, lng2){
// console.log(lat1)
var radLat1 = lat1 * Math.PI / 180.0;
var radLat2 = lat2 * Math.PI / 180.0;
 
var a = radLat1 - radLat2;
 
var b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
 
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;
 
s = Math.round(s * 10000) / 10000;
console.log(s)
return s;
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let that = this;
let a1,a2,b1,b2;
wx.chooseLocation({
success: function (res) {
a1 = res.latitude;
a2=res.longitude;
wx.chooseLocation({
success: function (res) {
b1 = res.latitude;
b2 = res.longitude;
console.log(a1)
console.log(a2)
console.log(b1)
console.log(b2)
that.GetDistance(a1, a2, b1, b2)
}
})
}
})
// wx.getLocation({
// type: 'wgs84',
// success: function (res) {
// console.log(res.latitude)
// console.log(res.longitude)
// }
// })
 
 
},

微信小程序 功能函数 地图定位相对直线距离的更多相关文章

  1. 微信小程序 功能函数 openid本地和网络请求

    本地-------------------------------------------------------------------------------------------------- ...

  2. 微信小程序 功能函数 点击传参和页面

    // 商品详情页跳转函数 detailInto: function (e) { // console.log() var change = e.currentTarget.dataset.id; wx ...

  3. 微信小程序 功能函数 支付接口

    // 订单生成返回数据,弹出是否支付模态 wx.showModal({ title: '微信支付', content: '确定支付吗?', success: function (res) { if ( ...

  4. 微信小程序 功能函数 定时震动

    ffn: function () { let nnn = this.data.nnn nnn += 1; this.setData({ nnn: nnn }); if (nnn > 10) { ...

  5. 微信小程序 功能函数 客服

    <view> <view class='btn-img'> <image class='image-full' src='../../imgs/index/tab6.pn ...

  6. 微信小程序 功能函数 将对象的键添加到数组 (函数深入)

    // 将对象的键添加到数组 var arr = Object.keys(site); //英文 https://developer.mozilla.org/en-US/docs/Web/JavaScr ...

  7. 微信小程序 功能函数 购物车商品删除

    // 购物车删除 deleteList(e) { const index = e.currentTarget.dataset.index; let carts = this.data.carts; c ...

  8. 微信小程序 功能函数 替换字符串内的指定字符

    var str = 'abcadeacf'; var str1 = str.replace('a', 'o'); alert(str1);    // 打印结果: obcadeacf   var st ...

  9. 微信小程序 功能函数picker-view的弹出模态

    <view class="list"> <form bindsubmit="formSubmit"> <view class=&q ...

随机推荐

  1. USB-Blaster驱动安装失败——文件哈希值不在指定目录中

    右击此电脑,选择管理,选择设备管理器,更新USB-Blaster驱动出现问题 问题: 文件的哈希值不在指定的目录文件中,如图: 解决办法: Windows键+R→shutdown.exe /r /o ...

  2. C语言字节对齐问题详解(对齐、字节序、网络序等)

    首先说明一下,本文是转载自: http://www.cnblogs.com/clover-toeic/p/3853132.html 博客园用的少,不知道怎么发布转载文章,只能暂时这样了. 引言 考虑下 ...

  3. 20155213 2016-2017-2 《Java程序设计》第二周学习总结

    20155213 2016-2017-2 <Java程序设计>第二周学习总结 教材学习内容总结 关于Unicode和UTF 很抱歉,没能读完娄老师推荐的网址,关于Unicode和UTF的介 ...

  4. 使用WinIO库实现保护模式下的IO和内存读写

    问题已解决: 原因是函数的调用方式与WinIO中不一致,使用的时候漏掉了__stdcall. 函数原定义为: 在实际的GPIO读写中遇到以下问题: SetPortVal可正常写入,但是GetPortV ...

  5. 解决循环里map不被重复覆盖的问题

    参考:https://blog.csdn.net/zyf642112750/article/details/78295113 这样就不会一直重复 项目管理系统 了

  6. abp core版本添加额外应用层

    1.新建类库WebProject.Application.App 2.添加WebProjectApplicationAppModule.cs 3.注册模块 using Abp.Application. ...

  7. Zigbee系列(end device)

    End device设备分为睡眠和非睡眠两种(RxOnWhenIdle标记不同). 入网时的association请求,会使用这个标记. 共同特性 子节点多次发送数据失败(无回应),发送孤点扫描(re ...

  8. 同一个电脑配置两个Git问题

    拿到公司电脑后,正常配置gitlab,以及设置邮箱等等,可以使用公司邮箱,以及一系列设置 git config --global user.name "userName" git ...

  9. Python多重赋值

    可以将变量名视对象的一个链接 >>>foo1 = foo2 = 4.3 >>>foo1 is foo2 True >>>foo1 = 4.3 &g ...

  10. ShipStation Now Uses AWS And Amazon Fulfillment To Automatically Ship From eBay, Sears And Other Marketplaces

    ShipStation today unveiled a first-of-its-kind service to leverage Amazon Web Services and Amazon.co ...