In my app, I permit the person to pick out which kind of map they’d like, then save/persist that choice with person defaults, which is analogous to most apps. I then name this operate to replace the show kind. I’ve up to date this to make use of the brand new MKMapConfiguration class for iOS 16 and above. This code works wonderful, however was questioning if that is how everybody was doing it.
One factor I seen is that the brand new MKStandardMapConfiguration is required as a way to get the complete DCE (detailed metropolis expertise). 3D bridges would not present on the older commonplace map kind.
func setMapType() {
let mapTypeDisplay = defaults.integer(forKey: "mapViewType")
if #obtainable(iOS 16, macOS 13, *) {
swap mapTypeDisplay {
case 1: mapView.preferredConfiguration = MKHybridMapConfiguration(elevationStyle: .flat)
case 2: mapView.preferredConfiguration = MKHybridMapConfiguration(elevationStyle: .life like)
default: mapView.preferredConfiguration = MKStandardMapConfiguration(elevationStyle: .life like, emphasisStyle: .default) }
} else {
//fallback to older variations
swap mapTypeDisplay {
case 1: mapView.mapType = MKMapType.hybrid
case 2: mapView.mapType = MKMapType.hybridFlyover
default: mapView.mapType = MKMapType.commonplace }
}
}