Did something change with Map in iOS 16?
Having trouble using the map component
1 Reply
eh used rthis code instead
import SwiftUI
import MapKit
struct Map: UIViewRepresentable {
func makeUIView(context: Context) -> MKMapView {
let mapView = MKMapView()
let coordinate = CLLocationCoordinate2D(latitude: 37.334_900, longitude: -122.009_020)
let span = MKCoordinateSpan(latitudeDelta: 0.1, longitudeDelta: 0.1)
let region = MKCoordinateRegion(center: coordinate, span: span)
mapView.setRegion(region, animated: true)
return mapView
}
func updateUIView(_ view: MKMapView, context: Context) {
}
}
struct MapView: View {
var body: some View {
Map()
}
}
struct Map_Previews: PreviewProvider {
static var previews: some View {
MapView()
}
}
import SwiftUI
import MapKit
struct Map: UIViewRepresentable {
func makeUIView(context: Context) -> MKMapView {
let mapView = MKMapView()
let coordinate = CLLocationCoordinate2D(latitude: 37.334_900, longitude: -122.009_020)
let span = MKCoordinateSpan(latitudeDelta: 0.1, longitudeDelta: 0.1)
let region = MKCoordinateRegion(center: coordinate, span: span)
mapView.setRegion(region, animated: true)
return mapView
}
func updateUIView(_ view: MKMapView, context: Context) {
}
}
struct MapView: View {
var body: some View {
Map()
}
}
struct Map_Previews: PreviewProvider {
static var previews: some View {
MapView()
}
}