geofirex
geofirex copied to clipboard
Firestore GeoPoint latitude and longitude errors
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
@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:
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.