modified: pages/basketballGym/index.js
modified: pages/basketballGym/index.wxml modified: pages/currentEnter/index.wxml modified: pages/loginIndex/index.js modified: pages/loginIndex/index.wxml modified: pages/loginIndex/index.wxss modified: pages/myEnters/index.wxml modified: utils/api.js modified: utils/util.js
This commit is contained in:
@@ -52,9 +52,22 @@ const getTimeoutStorage = (key) => {
|
||||
return value;
|
||||
}
|
||||
|
||||
// 计算两点之间的距离(返回米)
|
||||
const getDistance = (lat1, lng1, lat2, lng2) => {
|
||||
const radLat1 = lat1 * Math.PI / 180.0;
|
||||
const radLat2 = lat2 * Math.PI / 180.0;
|
||||
const a = radLat1 - radLat2;
|
||||
const b = lng1 * Math.PI / 180.0 - lng2 * Math.PI / 180.0;
|
||||
let 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) / 10; // 换算成米
|
||||
return s;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
formatTime: formatTime,
|
||||
getCurrentPageUrl: getCurrentPageUrl,
|
||||
setTimeOutStorage: setTimeOutStorage,
|
||||
getTimeoutStorage: getTimeoutStorage
|
||||
getTimeoutStorage: getTimeoutStorage,
|
||||
getDistance: getDistance
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user