I'm actually on a project where I'm using ReactNative and Firebase and I would like to set a geopoint data in Firebase, but when I update the doc on FB I have a wrong type of my data, the Geopoint is a map but I want a geopoint field.
Version in package.json :
"@react-native-firebase/app": "^12.8.0",
"@react-native-firebase/auth": "^12.8.0",
"@react-native-firebase/firestore": "^12.8.0",
"@react-native-firebase/storage": "^12.8.0",
"geofirex": "^0.1.0",
"rxjs": "^7.5.5",
this is my code :
import firebase from 'firebase/app';
import * as geofirex from 'geofirex';
import RNLocation from 'react-native-location';
const geo = geofirex.init(firebase);
useEffect(() => {
RNLocation.requestPermission({
ios: 'whenInUse',
android: {
detail: 'coarse',
},
});
this.locationSubscription = RNLocation.subscribeToLocationUpdates(
locations => {
const {latitude, longitude} = locations[0];
setCurrentLocation(locations[0]);
const location = geo.point(latitude, longitude);
if (currentUser?.location?.geohash !== location?.geohash) {
firestore().collection('users').doc(currentUID).update({
location,
});
}
},
);
}, []);
Now I show you the data on my FB :
But I want data like this (like array not map) :
I can't find where
I don't understand where the problem comes from and why it changes type !
Thanks in advance
I don't know the react specific implementation, but Firestore does not support geo-query directly, but you can implement it check this please, how they are doing in other languages,
https://firebase.google.com/docs/firestore/solutions/geoqueries