小程序端先将两点的经纬度获取到,然后传到后端通过高德计算出距离。
前端
/**
* 点击事件
* 点击获取起始地点
*/
begin:function(e){
var that = this
wx.chooseLocation({
latitude: 0,
success:function(res){
//维度
var b_latitude =(res.latitude)
//经度
var b_longitude =(res.longitude)
//将经纬度拼接起来
var b_address = b_longitude+','+b_latitude
that.setData({
b_address:b_address
})
}
})
},
/**
* 点击事件
* 获取终点
*/
end:function(){
var that = this
wx.chooseLocation({
latitude: 0,
success:function(res){
//经度
var e_latitude = (res.latitude)
//维度
var e_longitude = (res.longitude)
//经纬度