iOS 9 Swift Programming Cookbook (2015)
Chapter 8. Maps and Location
8.8 Showing Maps in Flyover Mode
Problem
You want to display your maps in a flyover state, where the regions on the map are translated onto a 3D globe, rather than a 2D flattened map.
Solution
Set the mapType property of your MKMapView to either HybridFlyover or SatelliteFlyover.
Discussion
The flyover mode of a map view represents the map as if it was on a globe, rather than flat. So keep that in mind when placing a camera on the map to show to the user.
Let’s start off with a single view controller app. Place a map view on your view and hook it up to your code. I’ve named mine “map”. When your view gets loaded, make sure that your map type is one of the aforementioned flyover modes:
map.mapType = .SatelliteFlyover
map.showsBuildings = true
Then when your view appears on the screen, set the camera on your map:
let loc = CLLocationCoordinate2D(latitude: 59.328564,
longitude: 18.061448)
let altitude: CLLocationDistance = 500
let pitch = CGFloat(45)
let heading: CLLocationDirection = 90
let c = MKMapCamera(lookingAtCenterCoordinate: loc,
fromDistance: altitude, pitch: pitch, heading: heading)
map.setCamera(c, animated: true)
Run this code on a real device (this doesn’t work very well on simulator) and you’ll get a display along the lines of Figure 8-8.
Figure 8-8. The Stockholm central station is shown here under satellite flyover mode
See Also