在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
})
})
}但我似乎不能让地球正确地保存下来。可能是因为我把它当作一根线,这是不对的?
在示例代码中,我只是把它硬编码到我知道的值中,这样我们就可以工作了。
发布于 2017-09-26 16:42:53
我认为这里的答案是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
})
})
}https://stackoverflow.com/questions/46431692
复制相似问题