如何以db.geo.point形式存储用户位置数据到云数据库中?
如何以db.geo.point形式存储用户位置数据到云数据库中?
//选择地址
chooseLocation: function () {
let that = this;
wx.chooseLocation({
success: function (res) {
console.log(res);
if (res.address) {
that.setData({
address: res.name,
latitude: res.latitude,
longitude: res.longitude,
})
app.globalData.latitude = res.latitude;
app.globalData.longitude = res.longitude;
app.globalData.address = res.address;
console.log(app.globalData)
}
}
})
},
//添加地址
addLocation: function () {
if (!this.data.address) {
wx.showToast({
title: '请选择地点!',
icon: 'none'
});
return;
}
const location = {
// type: this.data.locationType,
time: this.data.time,
address: this.data.address,
latitude: this.data.latitude,
longitude: this.data.longitude
};
this.data.loctaions.push(location);
this.setData({
loctaions: this.data.loctaions
});
},