I am trying to use the new Mapkit SwiftUI view and I am able to show a map with a certain region but I can't figure how to show a Map Marker.
This is what I have:
import SwiftUI
import MapKit
struct ContentView: View {
@State private var region = MKCoordinateRegion(center: CLLocationCoordinate2D(latitude: 38.8977, longitude: -77.0365), span: MKCoordinateSpan(latitudeDelta: 0.5, longitudeDelta: 0.5))
var location1 = MapMarker(coordinate: CLLocationCoordinate2D(latitude: 38.8977, longitude: -77.0365), tint: .red)
var body: some View {
Map(coordinateRegion: $region, showsUserLocation: true).edgesIgnoringSafeArea(.all)
}
}
Does anyone know how to add location1
to the Map? I found this but I have not been able to make it work