updateUserLocation method
Updates a user's location in a group
Implementation
Future<void> updateUserLocation(
String groupId,
String userId,
GeoPoint location, {
double? speed,
double? heading,
double? accuracy,
}) async {
try {
final data = {
'location': location,
'timestamp': FieldValue.serverTimestamp(),
};
// Add optional fields if provided
if (speed != null) data['speed'] = speed;
if (heading != null) data['heading'] = heading;
if (accuracy != null) data['accuracy'] = accuracy;
await _firestore
.collection(_collectionPath)
.doc(groupId)
.collection(_locationSubcollection)
.doc(userId)
.update(data);
} catch (e) {
print('Error updating location: $e');
rethrow;
}
}