I\'m trying to save a
CLLocationCoordinate2D
array into Firestore, but I\'m getting error:
\'FIRInvalidArgumentException\', reason: \'Unsupp
To break it down, Firebase doesn't know what a CLLocationCoordinate2D
object is. But it does know what an array is, and it does know what strings and integers and doubles are. So you will have to parse your array of locations into something it can understand. You can store the value in Firestore since a coordinate is really just a pair of double values. You can do this a number of ways, but the easiest is to probably split the locations array, one for the latitude values and one for longitude. For example, you can use let latitudes = locations.map({ $0.latitude })
and the same for longitudes. Then in Firestore, you would update it to something like:
"Person": txtfield_person.text!,
"What": txtfield_what.text!,
"Date": txtfield_Datum.text!,
"Time": txtfield_Time.text!,
"Timer": txtfield_timer.text!,
"Kilometers": txtfield_km.text!,
"LocationLatitudes": latitudes,
"LocationLongitudes": longitude,
]
Apply reverse logic for retrieving. You will need to iterate over the lat & long arrays and combine into a single array of CLLocationCoordinate2D
objects.