I’m using react native and have firestore structured like this. and i want access the geopoint latitude and longitude. how do i do that? sorry i’m still newbie
JavaScript
x
8
1
users:[{
2
name:""
3
geo_point:[latitude, longitutde]
4
},
5
{
6
name:""
7
geo_point:[latitude, longitutde]
8
}]
i’m getting error with this code
JavaScript
1
4
1
{this.state.users.map((user, idx) => <Marker
2
key={idx}
3
coordinate={{latitude: user.geo_point[0], longitude: user.geo_point[1]}}
4
>
Advertisement
Answer
Firestore GeoPoint
is not an array; it’s an object
you can access the lat & long using their field names, like below
JavaScript
1
2
1
coordinate={{latitude: user.geo_point.latitude, longitude: user.geo_point.longitude}}
2