In my app I'm refreshing data and as part of that I need my Map view and a MapMarker on that Map view to move with it. The Map view is moving as expected, but the MapMarker is remaining where it is when the view is first presented.
Code Block swift struct MapView: View { @Binding var train: Train @Binding var region: MKCoordinateRegion @Binding var marker: MapMarker var body: some View { Map(coordinateRegion: $region, interactionModes: .zoom, annotationItems: [train], annotationContent: { (_) in return marker }) .edgesIgnoringSafeArea(.bottom) .navigationBarTitle("Train #\(train.runNumber)") } } struct MapView_Previews: PreviewProvider { @State static var train = sampleTrain1 @State static var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: sampleTrain1.position!.latitude, longitude: sampleTrain1.position!.longitude), latitudinalMeters: 1000, longitudinalMeters: 1000) @State static var marker = MapMarker(coordinate: region.center) static var previews: some View { NavigationView { MapView(train: $train, region: $region, marker: $marker) } } }