I have the following code and when trying to add Animation, I get the following error: "Cannot find 'withAnimation' in scope error" Is there something I'm missing please? import Foundation import MapKit class LocationsViewModel: ObservableObject {
//All loaded locations @Published var locations: [Locations]
//Current location on the map @Published var mapLocation: Locations
@Published var mapRegion: MKCoordinateRegion = MKCoordinateRegion() let mapSpan = MKCoordinateSpan(latitudeDelta: 0.1, longitudeDelta: 0.1)
init() { let locations = LocationsDataService.locations self.locations = locations self.mapLocation = locations.first!
self.updateMapRegion(locations: locations.first!)
}
private func updateMapRegion (locations:Locations) { withAnimation(.easeInOut) { mapRegion = MKCoordinateRegion( center: Locations.coordinates, span: mapSpan) }