I am working on a virtual simulator for iOS 17 from my macbook.
I want to have the initial view present the Map but zoomed out enough so that it's basically showing the whole world - in a 3d render.
My understanding is that as of iOS17 if you have .standard
for the MKMapView
type, it should still render as 3D if the altitude is high enough. But on my simulator, I literally cannot zoom out any further.
Is the right protocol to update the mapType to be .hybridFlyover
? That seems different than the .standard (which I think is what I actually want).
Does anyone have any idea / is there anything sticking out in this code?
Here is my code:
struct GlobeView: UIViewRepresentable {
var coordinates: [IdentifiableCoordinate]
func makeUIView(context: Context) -> MKMapView {
let mapView = MKMapView()
mapView.mapType = .hybridFlyover
mapView.delegate = context.coordinator
let camera = MKMapCamera(lookingAtCenter: CLLocationCoordinate2D(latitude: 0, longitude: 0), fromDistance: 1_000_000_000, pitch: 0, heading: 0)
mapView.setCamera(camera, animated: true)
return mapView
}
func updateUIView(_ uiView: MKMapView, context: Context) {
let annotations = coordinates.map { coordinate -> MKPointAnnotation in
let annotation = MKPointAnnotation()
annotation.coordinate = coordinate.coordinate
return annotation
}
uiView.addAnnotations(annotations)
}
class Coordinator: NSObject, MKMapViewDelegate {
var parent: GlobeView
init(_ parent: GlobeView) {
self.parent = parent
}
}
func makeCoordinator() -> Coordinator {
Coordinator(self)
}
}