问题描述
在数据库UI中,我可以创建类型为geopoint
的字段.提供值后,看起来像这样:location: [1° N, 1° E]
我正在尝试通过客户端SDK(网络)将其保存到数据库中.根据Twitter反馈,我尝试了GeoJSON,Coords Array和Coords Object:
location: [1, 2];
location: {
latitude: 1,
longitude: 2,
};
location: {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1]
}
}
没有一个导致数据库中的geopoint类型.它们只是保存为对象/数组.
如何通过Web SDK在Firebase Cloud Firestore中保存GeoPoint?
Firestore SDK包含 GeoPoint class
,因此您必须保存以下位置:
{
location: new firebase.firestore.GeoPoint(latitude, longitude)
}
in the database UI I can create a field with the type geopoint
. After providing values, it looks something like this:
location: [1° N, 1° E]
I'm trying to save this to the DB via client side SDK (web).Based on Twitter Feedback I tried GeoJSON, Coords Array and Coords Object:
location: [1, 2];
location: {
latitude: 1,
longitude: 2,
};
location: {
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [125.6, 10.1]
}
}
None of which resulted in the geopoint type in the database. They're just saved as Objects/Arrays.
How to save GeoPoint in Firebase Cloud Firestore via the Web SDK?
The Firestore SDKs include a GeoPoint class
, so you would have to save locations like this:
{
location: new firebase.firestore.GeoPoint(latitude, longitude)
}
这篇关于如何在Firebase Cloud Firestore中保存GeoPoint?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!