geoFirestore仅从集合中加载1个文档没有将所有地理点加载到地图 [需要]描述您的环境

问题描述

我正在使用geoFireStore使用Firestore保存和查询位置信息。我从这里分叉了这个例子 https://github.com/MichaelSolati/geofirestore-js

[需要]描述您的环境

  • 操作系统版本:MacOS
  • 浏览器版本:Google chrome的最新版本
  • Firebase库(firebasefirebase-admin等...)和版本:7.15.0
  • GeoFirestore版本:最新

我分叉了观众库 我添加了自己的火力基地 我创建了自己的文档集合 我添加了两个参数“ city”和“ interestingFact” 文件进入收藏集就好了

描述错误

显示我的位置。我添加的所有标记都没有出现

重现步骤
  1. 转到“ ...”
  2. 点击“ ...”。
  3. 滚动到“ ....”
  4. 看到错误
相关代码

jaredgibb.github.io/viewers/ ^^^^^所有代码都可以@R_502_6329@找到^^^^^^

原始代码如下。唯一的变化发生在“数据”模型上

function getInFirestore(location) {
  location.lat = Number(location.lat.toFixed(1));
  location.lng = Number(location.lng.toFixed(1));
  const hash = Geokit.hash(location);

  geoCollectionRef.doc(hash).get().then((snapshot) => {
    let data = snapshot.data();
    if (!data) {
      data = {
        count: 1,coordinates: new firebase.firestore.GeoPoint(location.lat,location.lng)
      };
      console.log('Provided key is not in Firestore,adding document: ',JSON.stringify(data));
      createInFirestore(hash,data);
    } else {
      data.count++;
      console.log('Provided key is in Firestore,updating document: ',JSON.stringify(data));
      updateInFirestore(hash,data);
    }
  },(error) => {
    console.log('Error: ' + error);
  });
}

代码

function getInFirestore(location,city,interestingFact) {
  location.lat = Number(location.lat.toFixed(1));
  location.lng = Number(location.lng.toFixed(1));
  const hash = Geokit.hash(location);

  geoCollectionRef.doc(hash).get().then((snapshot) => {
    let data = snapshot.data();
    if (!data) {
      data = {
        city: city,interestingFact: interestingFact,data);
    } else {

      console.log('Provided key is in Firestore,(error) => {
    console.log('Error: ' + error);
  });
}

出现在屏幕上的原始文档 document that is queryable before changing the code

此图演示了文档的创建。 screenshot showing that documents are created with new model

似乎代码仅接收1个文档。我对JS很陌生,我迷路了。任何帮助将不胜感激! screenshot of console printout

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)