关于距离计算的问题?
onShow: function () {
var that = this;
that.getDistance()
}
getDistance: function () {
var that = this;
let destinationDistance;
demo.calculateDistance({
to: [{
latitude: app.globalData.user.latitude ,
longitude: app.globalData.user.longitude
}],
success: function (res) {
destinationDistance = res.result.elements[0].distance;
let distanceKm = `${(destinationDistance / 1000).toFixed(2)}`;
console.log('DIS',distanceKm)
that.setData({
distance: distanceKm
})
},
fail: function (res) {
console.log('ERROR',res);
}
});
}
<cover-view wx:if="{{address}}">
({{distance}}KM)
</cover-view>