MichaelSolati / geofirestore-js

Location-based querying and filtering using Firebase Firestore.
https://geofirestore.com
MIT License
505 stars 58 forks source link

e.docChanges is not a function #19

Closed kingtross88 closed 6 years ago

kingtross88 commented 6 years ago

I keep getting the above error when I run a query. Can anyone point me in the right direction?

const geoQuery = geoFirestore.query({ center: new firebase.firestore.GeoPoint(this.state.region, this.state.region.longitude), radius: 10.5 });

MvRemmerden commented 6 years ago

Looks like you forgot the .latitude in your first argument.

For everything else, we would need to see more of your code.

kingtross88 commented 6 years ago

I'm sorry I wrote it out wrong. I should've just pasted from my code rather than type it over. I'm still getting the same error. I'm running the getCurrentPosition function in componentDidMount.

getCurrentPosition(){ navigator.geolocation.getCurrentPosition((position) => { region = { latitude: position.coords.latitude, longitude: position.coords.longitude, latitudeDelta: 0.00922, longitudeDelta: 0.00421, error: null, } this.setState({ region, }); }, (error) => this.setState({ error: error.message }), { enableHighAccuracy: true, timeout: 20000, maximumAge: 1000 },

);

}

then I run the following code in another function. var ref = firebase.firestore().collection('myCollection'); const geoFirestore = new GeoFirestore(this.ref); const geoQuery = geoFirestore.query({ center: new firebase.firestore.GeoPoint(this.state.region.latitude, this.state.region.longitude), radius: 10.5 });

MvRemmerden commented 6 years ago

Which version of firebase and geofirestore are you using?

kingtross88 commented 6 years ago

geofirestore "version": "2.0.2" firebase "version": "4.13.1"

MvRemmerden commented 6 years ago

Try to update firebase to any version above 5.0.0, they changed docChanges into a method at that release, so it might be possible that the geofirestore code tries to access a variable that now is a function.

MichaelSolati commented 6 years ago

@MvRemmerden is absolutely correct, geofirestore is designed for firebase version5.x.x. Try that and you should be all set.

MichaelSolati commented 6 years ago

@kingtross88 let me know if updating your firebase did the trick for you. If we don't hear back I'll be closing this in a day or so.

kingtross88 commented 6 years ago

still working on getting this done. I did an update on my react native and now my project won't build. I'll get this sorted out today and let you know.

Thank you!

kingtross88 commented 6 years ago

updated firebase and did a node update. closing this out