Skip to content Skip to sidebar Skip to footer

How To Get Firestore Geopoint Value In Nested Object?

Here is my temporary code for generate geopoint datatype from Firestore DB firestoreDb.collection('products').document(productId).get() .addOnSuccessListener(documentSnapshot -&g

Solution 1:

You post two different code and one of them provides you proper answer :

String stringGeoPoint = products.getLocation().get("geoPoint").toString();

and this line of code shows null :

GeoPointgeoPoint= documentSnapshot.getGeoPoint(stringGeoPoint);

Reason :

The reason behind the first code works properly because when you retrieving data you have created data model for the documents field. you have you method as getLocation() which will return the Location array. Then you can normally look into hashmap array by passing the key of hashmap

Location is an Array of Hashmap<String, String>.

So the 2nd code won't work for you cause there is no field under the documentSnapshot.

Post a Comment for "How To Get Firestore Geopoint Value In Nested Object?"