Hello,
I am facing SwiftUI runtime warnings while implementing MapAnnotation
[SwiftUI] Publishing changes from within view updates is not allowed, this will cause undefined behavior.
, there are new warnings when the map is moved.
Implementing MapMarker instead of MapAnnotation solves the problem. What am I doing wrong with MapAnnotation?
The code is running on Xcode version 14.1 (14B47b) and Simulator Version 14.1 (986.5)
struct AnnotationItem: Identifiable {
let id = UUID()
var coordinate: CLLocationCoordinate2D
}
struct MapView: View {
@Binding var region: MKCoordinateRegion
@Binding var items: [AnnotationItem]
var body: some View {
Map(coordinateRegion: $region,
annotationItems: items) { item in
MapAnnotation(coordinate: item.coordinate) {
Image(systemName: "cup.and.saucer.fill")
}
}
}
}