How can I write array of coordinates to Cloud Firestore

前端 未结 2 687
滥情空心
滥情空心 2021-01-24 19:05

How can I write an array of coordinates to the Cloud Firestore as a GeoPoint datatype?

I do have an arraylist points with coordin

2条回答
  •  时光说笑
    2021-01-24 19:11

    When passing FieldValue.arrayUnion as the second argument to the update() method like in the the following line of code:

    docRef.update("Test", FieldValue.arrayUnion(points));
    

    It means that you are telling Firebase that you want to update a property within a document which is of type array with a List, which is actually not possible, hence this error:

    Nested arrays not supported
    

    If you have documents that contain nested arrays, please note that a regular update is currently not possible. What can you do instead is to get the entire document and call getData() on the DocumentSnapshot object. The type of object that is returned is a Map. Iterate through the map, update the desired value and write the document back in the database.

提交回复
热议问题