在 Baqend 中保存 GeoPoint 的正确语法是什么?
What is the correct syntax for saving a GeoPoint in Baqend?
在 Baqend 中保存经纬度的正确语法是什么?
我成功保存了普通字段(都是字符串):
handleSubmit(event) {
event.preventDefault();
var newcompany = new db.Companies({
name: this.state.name,
photo: '',
geo: '47.626814;-122.357345',
address1: this.state.address1,
address2: this.state.address2,
city: this.state.city,
state: this.state.state,
zip: this.state.zip,
});
newcompany.insert().then(() => {
//console.log(newcompany)
this.setState({
redirect: true,
newcompanykey: newcompany.key
})
})
}
但我似乎无法正确保存地理信息。可能是因为我将其视为字符串,但这是不正确的?
在示例代码中,我现在只是将其硬编码为我认为合适的值,以便我们可以正常工作。
我认为这里的答案是sdk提供了一个正确编码的函数:
handleSubmit(event) {
event.preventDefault();
var geo = new db.GeoPoint(47.626814, -122.357345)
var newcompany = new db.Companies({
name: this.state.name,
photo: '',
geo: geo,
address1: this.state.address1,
address2: this.state.address2,
city: this.state.city,
state: this.state.state,
zip: this.state.zip,
});
newcompany.insert().then(() => {
//console.log(newcompany)
this.setState({
redirect: true,
newcompanykey: newcompany.key
})
})
}
在 Baqend 中保存经纬度的正确语法是什么?
我成功保存了普通字段(都是字符串):
handleSubmit(event) {
event.preventDefault();
var newcompany = new db.Companies({
name: this.state.name,
photo: '',
geo: '47.626814;-122.357345',
address1: this.state.address1,
address2: this.state.address2,
city: this.state.city,
state: this.state.state,
zip: this.state.zip,
});
newcompany.insert().then(() => {
//console.log(newcompany)
this.setState({
redirect: true,
newcompanykey: newcompany.key
})
})
}
但我似乎无法正确保存地理信息。可能是因为我将其视为字符串,但这是不正确的?
在示例代码中,我现在只是将其硬编码为我认为合适的值,以便我们可以正常工作。
我认为这里的答案是sdk提供了一个正确编码的函数:
handleSubmit(event) {
event.preventDefault();
var geo = new db.GeoPoint(47.626814, -122.357345)
var newcompany = new db.Companies({
name: this.state.name,
photo: '',
geo: geo,
address1: this.state.address1,
address2: this.state.address2,
city: this.state.city,
state: this.state.state,
zip: this.state.zip,
});
newcompany.insert().then(() => {
//console.log(newcompany)
this.setState({
redirect: true,
newcompanykey: newcompany.key
})
})
}