当前位置:网站首页>Wechat applet calculates the distance between the two places
Wechat applet calculates the distance between the two places
2022-07-02 04:04:00 【Minced pork, pumpkin and scallop】
// Packaging function Calculated distance
distance: function (la1, lo1, la2, lo2) {
var La1 = la1 * Math.PI / 180.0;
var La2 = la2 * Math.PI / 180.0;
var La3 = La1 - La2;
var Lb3 = lo1 * Math.PI / 180.0 - lo2 * Math.PI / 180.0;
var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(La3 / 2), 2) + Math.cos(La1) * Math.cos(La2) * Math.pow(Math.sin(Lb3 / 2), 2)));
s = s * 6378.137;
s = Math.round(s * 10000) / 10000;
s = s.toFixed(2);
return s;
},
// Send a request to query the longitude and latitude of the destination Get current location Usage method
onLoad: function (options) {
let _this = this
let id = options.id;
wx.request({
url: 'http://www.week.com/index.php/msg',
data:{id:id},
success(e){
let data = e.data.data;
let latitude= e.data.data.latitude;
let longitude=e.data.data.longitude;
wx.getLocation({
success(e){
let la = e.latitude
let lo = e.longitude
let distance = _this.distance(la,lo,latitude,longitude)
_this.setData({distance})
}
})
_this.setData({data,latitude,longitude})
}
})
}
边栏推荐
- 【人员密度检测】基于形态学处理和GRNN网络的人员密度检测matlab仿真
- The 7th Blue Bridge Cup single chip microcomputer provincial competition
- 【小技巧】使用matlab GUI以对话框模式读取文件
- First acquaintance with P4 language
- Use a mask to restrict the input of the qlineedit control
- Learn more about materialapp and common attribute parsing in fluent
- Delete the code you wrote? Sentenced to 10 months!
- The 9th Blue Bridge Cup single chip microcomputer provincial competition
- [untitled]
- Lei Jun wrote a blog when he was a programmer. It's awesome
猜你喜欢
QT designer plug-in implementation of QT plug-in
文档声明与字符编码
66.qt quick QML Custom Calendar component (supports vertical and horizontal screens)
Microsoft Research Institute's new book "Fundamentals of data science", 479 Pages pdf
Introduction to vmware workstation and vSphere
Vite: configure IP access
Analysis of the overall design principle of Nacos configuration center (persistence, clustering, information synchronization)
[untitled]
Sword finger offer II 006 Sort the sum of two numbers in the array
滴滴开源DELTA:AI开发者可轻松训练自然语言模型
随机推荐
QT designer plug-in implementation of QT plug-in
如何解决在editor模式下 无法删除物体的问题
A thorough understanding of the development of scorecards - the determination of Y (Vintage analysis, rolling rate analysis, etc.)
手撕——排序
[tips] use Matlab GUI to read files in dialog mode
Today's plan: February 15, 2022
The 8th Blue Bridge Cup single chip microcomputer provincial competition
Wechat applet - realize the countdown of 60 seconds to obtain the mobile verification code (mobile number + verification code login function)
go 分支与循环
Go variables and constants
regular expression
WPViewPDF Delphi 和 .NET 的 PDF 查看组件
Blue Bridge Cup single chip microcomputer sixth temperature recorder
《动手学深度学习》(二)-- 多层感知机
go 包的使用
Welcome the winter vacation multi school league game 2 partial solution (B, C, D, F, G, H)
2022-07-01: at the annual meeting of a company, everyone is going to play a game of giving bonuses. There are a total of N employees. Each employee has construction points and trouble points. They nee
Recyclerview add header
Go语言介绍
BGP experiment the next day