当前位置:网站首页>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})
}
})
}边栏推荐
- MySQL error: expression 1 of select list is not in group by claim and contains nonaggre
- Use of go package
- [personal notes] PHP common functions - custom functions
- Pandora IOT development board learning (HAL Library) - Experiment 2 buzzer experiment (learning notes)
- 毕设-基于SSM电影院购票系统
- 云服务器的安全设置常识
- The 11th Blue Bridge Cup single chip microcomputer provincial competition
- pip 安装第三方库
- The first practical project of software tester: web side (video tutorial + document + use case library)
- [untitled]
猜你喜欢

手撕——排序

JVM知识点

Lei Jun wrote a blog when he was a programmer. It's awesome

The fourth provincial competition of Bluebridge cup single chip microcomputer

蓝湖的安装及使用

MySQL error: expression 1 of select list is not in group by claim and contains nonaggre
![[JS event -- event flow]](/img/fe/199890b082845f68b65f25056e6f29.jpg)
[JS event -- event flow]

Li Kou interview question 02.08 Loop detection

Visual slam Lecture 3 -- Lie groups and Lie Algebras

First acquaintance with P4 language
随机推荐
【力扣刷题】15.三数之和(双指针);17.电话号码的字母组合(递归回溯)
5G时代全面到来,浅谈移动通信的前世今生
[JS -- map string]
[personal notes] PHP common functions - custom functions
[untitled]
The 9th Blue Bridge Cup single chip microcomputer provincial competition
【小技巧】使用matlab GUI以对话框模式读取文件
Microsoft Research Institute's new book "Fundamentals of data science", 479 Pages pdf
cookie、session、tooken
Which is better, industrial intelligent gateway or edge computing gateway? How to choose the right one?
go 语言命名规范
Qt插件之Qt Designer插件实现
Go branch and loop
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
Hand tear - sort
"No war on the Western Front" we just began to love life, but we had to shoot at everything
Feature Engineering: summary of common feature transformation methods
QT designer plug-in implementation of QT plug-in
Www2022 | know your way back: self training method of graph neural network under distribution and migration
Introduction to vmware workstation and vSphere