javascript - 如何在 Firebase Firestore 中将 Web 表单(Javascript)条目添加或保存为 GeoPoint 类型
问题描述
嗨,我有一个收集以下内容的网络表单:
-cafe 名称 -latitude -其位置的经度。
目前,经纬度在 Firestore 中保存为地图格式,而不是 GeoPoint。因此,我想就如何将其保存为 GeoPoint 格式/数据类型征求您的意见。
form.addEventListener('submit',(e)=>{
e.preventDefault();
db.collection('sgcafe').add ({
name: form.name.value,
category: form.category.value,
coordinates: {Latitude:form.lat.value,Longtitude:form.long.value} //save as map not Geopoint
我尝试了以下所有方法,但它不起作用。
coordinates: new firebase.firestore.GeoPoint(form.lat.value, form.long.value)
coordinates: firebase.firestore.GeoPoint(form.lat.value, form.long.value)
coordinates: GeoPoint(form.lat.value, form.long.value)
解决方案
如果我是对的,您需要将坐标数组发送到您的 firestore 数据库,因此在添加之前尝试此操作,然后将数组 av 值传递给对象的坐标键。
let coords = []
coords.push(new firebase.firestore.GeoPoint(form.lat.value, form.long.value))
推荐阅读
- azure-ad-b2c - Microsoft InTune 是否适用于 Azure AD B2C
- google-sheets - Google表格中的条件格式冲突
- kubernetes - 在 Kubernetes 中,为什么 NodePort 的默认端口范围是 30000 - 32767?
- c# - 英雄联盟直播 API 使用
- linux - 链接有效,但 ldd 不显示链接库并且运行时失败
- java - 清单文件没有被添加?
- puppeteer - 傀儡师。waitForNavigation 在等什么?
- spring-boot - Activiti 框架:resultVariableName 奇怪的行为
- excel - 如何按特定范围拆分长行并将其添加为新行 - Excel
- python - Matlab 等价于 Python 的“+=”运算符用于数独问题