Giter VIP home page Giter VIP logo

Comments (6)

MichaelSolati avatar MichaelSolati commented on June 9, 2024

I'm assuming you're testing version 3 of the library. With that in mind I don't believe your import syntax for for firebase is correct. Also you need to instantiate a firestore object, which I don't see.

I see some similarities in what you have to the sample I have in the readme, please give it another look though https://github.com/geofirestore/geofirestore-js/blob/v3.0.0/README.md#documentation

And if you have any questions let me know. I'll keep the issue open till Sunday so you can let me know if that works.

from geofirestore-js.

razbakov avatar razbakov commented on June 9, 2024

I updated the code, basically I have the part of the code of initialising app and firestore in a separate file.

from geofirestore-js.

MichaelSolati avatar MichaelSolati commented on June 9, 2024

@razbakov what version are you using? (And would you possibly be cool with making sample of on something like https://codepen.io/ ??)

from geofirestore-js.

razbakov avatar razbakov commented on June 9, 2024

My versions are:

"firebase": "^5.6.0",
"geofirestore": "^2.2.3",

from geofirestore-js.

razbakov avatar razbakov commented on June 9, 2024

Here is example - https://codesandbox.io/s/y04wj6zpoj

from geofirestore-js.

MichaelSolati avatar MichaelSolati commented on June 9, 2024

Ok! This I can easily address. I think you may have been referencing the documentation for version 3 which is located on geofirestore.com, however you're using version 2.x.x

Check out the docs for version 2

And as an example on how to do what you wanted to do...

import * as firebase from 'firebase/app';
import 'firebase/firestore';
import { GeoFirestore } from 'geofirestore'

// Initialize the Firebase SDK
firebase.initializeApp({
  // ...
});

// Array to store events
let events = [];

// Create a Firestore collection reference
const collection = firebase.firestore().collection('events');

// Create a GeoFirestore reference
const geofirestore = new GeoFirestore(collection);

// Create a GeoQuery based on a location
const query = geofirestore.query({ center: new firebase.firestore.GeoPoint(48.1077212, 11.6019103), radius: 50 })

// Listener for docs as they come in
query.on('key_entered', ($key, result) => {
    result.$key = $key;
    events.push(result);
});

// Listener for docs as they exit
query.on('key_exited', ($key) => {
    events = events.filter((event) => event.$key !== $key));
});

IF however you want to use version 3.0.0 (as your current code shows), you can install it like this:

npm i geofirestore/geofirestore-js#v3.0.0

It's still in kind of a beta state, however it's almost good to go, and I feel comfortable saying you could/should try it. I'm just writing tests to validate it works, otherwise the development is pretty much done (unless a test tells me I screwed up)

from geofirestore-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.