map issue- i keep having this warning is there any solution

'init(coordinateRegion:interactionModes:showsUserLocation:userTrackingMode:)' was deprecated in iOS 17.0: Use Map initializers that take a MapContentBuilder instead.

struct EmMapView: View { @State private var region = MKCoordinateRegion( center: CLLocationCoordinate2D(latitude: 37.7749, longitude: -122.4194), span: MKCoordinateSpan(latitudeDelta: 0.1, longitudeDelta: 0.1) )

var body: some View {
    ZStack {
        Map(coordinateRegion: .constant(region), interactionModes: .all, showsUserLocation: false, userTrackingMode: .none)
            .edgesIgnoringSafeArea(.all)
            .navigationTitle("Emmap")
    }
}

}

Replies

It's just a deprecation message. You can either continue to use your existing code until Apple decides that the code is no longer supported (in which case your app won't build); or you can change it. I use something like this:

@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)

var body: some View {
	Map(position: $mapPosition) {
		Marker(mapMarkerName, coordinate: coordinates)
	}
	.mapStyle(.standard(elevation: .realistic))
	.mapControls {
		MapCompass()
		MapScaleView()
	}
}