Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firestore GeoPoint latitude and longitude errors #116

Open
lucapale opened this issue Apr 7, 2020 · 2 comments
Open

Firestore GeoPoint latitude and longitude errors #116

lucapale opened this issue Apr 7, 2020 · 2 comments

Comments

@lucapale
Copy link

lucapale commented Apr 7, 2020

Hi,
I have noticed that in my app the GeoPoint is stored as: {Wa:number, za:number} instead of latitude and longitude as used in your code.
I have modified the "filter" inside the "within" function as follows:
var _a = val[field].geopoint, latitude = _a.latitude ? _a.latitude : _a.Wa, longitude = _a.longitude ? _a.longitude :_a.za;

With this is works.
Bye
Luca

@StevieWag
Copy link

@lucapale can you explain in more detail where you put this?

I also have the problem, that the point object is stored differently in some cases. The pattern I can see on my side so far is that this happens when the created object is set to firestore through a transaction.

Then the object looks like this and I cannot query it with the proposed within query from the documentation:

image

@lucapale
Copy link
Author

I have noticed that Firebase stored the information in this way because I was converting all the data to JSON before writing it (i.e. JSON.parse(JSON.stringify(object)) ).
This because Firebase does not accept classes which are not known. Now I keep at least the geolocation information as class inside the object and Firebase stores it in the correct way.
For the previous data I have made a function which converts again the stored object into a Geopoint, before making the query.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants