Check Map's initializer called when you move Map's region.
This is simple example
class PlaceViewModel: ObservableObject {
var region: MKCoordinateRegion = .seoul
@Published var places: [Place] = []
}
struct PlaceView: View {
@StateObject var viewModel = PlaceViewModel()
var body: some View {
ZStack(alignment: .top) {
Map(
coordinateRegion: $viewModel.region,
annotationItems: viewModel.places
) { item in
MapAnnotation(coordinate: item.location) {
Text(item.title)
}
}
}
}
}