当前位置:网站首页>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})
}
})
}边栏推荐
- The original author is out! Faker. JS has been controlled by the community..
- Didi open source Delta: AI developers can easily train natural language models
- First acquaintance with P4 language
- Www 2022 | rethinking the knowledge map completion of graph convolution network
- 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
- [ibdfe] matlab simulation of frequency domain equalization based on ibdfe
- Realizing deep learning framework from zero -- Introduction to neural network
- [JS -- map string]
- go 语言命名规范
- regular expression
猜你喜欢

PIP installation of third-party libraries

The second game of the 12th provincial single chip microcomputer competition of the Blue Bridge Cup

The first practical project of software tester: web side (video tutorial + document + use case library)

MySQL advanced SQL statement 2

Blue Bridge Cup single chip microcomputer sixth temperature recorder

It took me only 3 months to jump out of the comfort zone and become an automated test engineer for 5 years

Lost a few hairs, and finally learned - graph traversal -dfs and BFS

Sorted out an ECS summer money saving secret, this time @ old users come and take it away

Pandora IOT development board learning (RT thread) - Experiment 1 LED flashing experiment (learning notes)

How to model noise data? Hong Kong Baptist University's latest review paper on "label noise representation learning" comprehensively expounds the data, objective function and optimization strategy of
随机推荐
How should the team choose the feature branch development mode or trunk development mode?
2022-07-01:某公司年会上,大家要玩一食发奖金游戏,一共有n个员工, 每个员工都有建设积分和捣乱积分, 他们需要排成一队,在队伍最前面的一定是老板,老板也有建设积分和捣乱积分, 排好队后,所有
"No war on the Western Front" we just began to love life, but we had to shoot at everything
向数据库中存入数组数据,代码出错怎么解决
Jetpack之LiveData扩展MediatorLiveData
Raspberry pie GPIO pin controls traffic light and buzzer
Target free or target specific: a simple and effective zero sample position detection comparative learning method
一文彻底理解评分卡开发中——Y的确定(Vintage分析、滚动率分析等)
Go语言介绍
[JS event -- event flow]
5g era is coming in an all-round way, talking about the past and present life of mobile communication
Go function
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
WPViewPDF Delphi 和 .NET 的 PDF 查看组件
go 包的使用
Which is better, industrial intelligent gateway or edge computing gateway? How to choose the right one?
SQL: common SQL commands
【小技巧】使用matlab GUI以对话框模式读取文件
A thorough understanding of the development of scorecards - the determination of Y (Vintage analysis, rolling rate analysis, etc.)
MySQL error: expression 1 of select list is not in group by claim and contains nonaggre