SwiftUI iOS 17, Xcode 15.3 MapContentBuilder

I consistently get an error that the Map initailizer I'm using is deprecated and I should use a MapContent builder instead. Various errors such as "'MapAnnotation' was deprecated in iOS 17.0: Use Annotation along with Map initializers that take a MapContentBuilder instead." or "'init(coordinateRegion:interactionModes:showsUserLocation:userTrackingMode:annotationItems:annotationContent:)' was deprecated in iOS 17.0: Use Map initializers that take a MapContentBuilder instead."

The problem in my code seems to be located here: import SwiftUI import MapKit

struct ContentView: View { @State private var region = MKCoordinateRegion( center: CLLocationCoordinate2D(latitude: 34.0522, longitude: -118.2437), span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5) )

@State private var restaurants: [Restaurant] = []

var body: some View {
    Map(coordinateRegion: $region, annotationItems: restaurants) { restaurant in
        // This uses the updated Annotation API
        MapAnnotation(coordinate: restaurant.coordinate) {
            VStack {
                Text(restaurant.restaurantName)
                    .bold()
                    .foregroundColor(.white)
                    .padding(5)
                    .background(Color.black.opacity(0.75))
                    .cornerRadius(10)
                    .fixedSize()
                Image(systemName: "mappin.circle.fill")
                    .foregroundColor(.red)
                    .font(.title)
            }
        }

The errors persistently occur in the lines immediately below var body: some View { I've been stuck on this for two days now. Any help would be greatly appreciated.

I hit those warnings, too. You can ignore them until they become errors, but if you want to correct them now you can use something like this, and munge it around to fit your needs:

	@State private var mapPosition = MapCameraPosition.region(MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 51.507222, longitude: -0.1275), span: MKCoordinateSpan(latitudeDelta: 0.03, longitudeDelta: 0.03)))
	@State private var coordinates = CLLocationCoordinate2D(latitude: 51.507222, longitude: -0.1275)
	@State private var mapInteractionModes: MapInteractionModes = []
	@State private var mapMarkerName: String = "My Marker"

...

	Map(position: $mapPosition) {
		Marker(mapMarkerName, coordinate: coordinates)
	}
	.mapStyle(.standard(elevation: .realistic))
	.mapControls {
		MapCompass()
		MapScaleView()
	}
SwiftUI iOS 17, Xcode 15.3 MapContentBuilder
 
 
Q