Oleksii
Oleksii

Reputation: 803

Apple MapKit 3D flyover

Is there any public iOS 8 API available to implement 3D flyover or at least 3D view as shown on Apple Maps App screenshot below?

enter image description here

Update

After below suggestions I've done following code:

import UIKit
import MapKit

class ViewController: UIViewController {

    @IBOutlet weak var mapView: MKMapView!
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        mapView.showsBuildings = true
        let eiffelTowerCoordinates = CLLocationCoordinate2DMake(48.85815,2.29452)
        mapView.region = MKCoordinateRegionMakeWithDistance(eiffelTowerCoordinates, 1000,100)

        mapView.mapType = MKMapType.Standard

        // 3D Camera
        let mapCamera = MKMapCamera()
        mapCamera.centerCoordinate = eiffelTowerCoordinates
        mapCamera.pitch = 45
        mapCamera.altitude = 500
        mapCamera.heading = 45

        // Set MKmapView camera property
        self.mapView.camera = mapCamera
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

Now my App looks similar to Apple Maps App but unfortunately not identical.

enter image description here

Is anybody knows how to add all textures to buildings?

Update 2

Google Maps iOS SDK checked. Absolutely same story. No 3D buildings in any mode except kGMSTypeNormal That means no textured buildings available.

Following code:

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
        let camera = GMSCameraPosition.cameraWithLatitude(48.85815, longitude: 2.29452, zoom: 50, bearing:30, viewingAngle:40)
        let mapView = GMSMapView.mapWithFrame(CGRectZero, camera: camera)
        mapView.mapType = kGMSTypeNormal
        mapView.buildingsEnabled = true
        self.view = mapView

    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
}

Renders following screenshot:

enter image description here

Upvotes: 11

Views: 10002

Answers (4)

Jayprakash Dubey
Jayprakash Dubey

Reputation: 36447

mapType property of MKMapView enum can be used to change the map type or region.

Screenshot 1

You can use hybridFlyover property to show satellite image along with flyover data where it is available.

Usage:

objMapView.mapType = .hybridFlyover

Here, objMapView is an instance of MKMapView class.

Screenshot 2

Upvotes: 0

François Lagunas
François Lagunas

Reputation: 571

You can now use the new iOS 9 MKMapTypeSatelliteFlyover type.

Test App Screenshot

Upvotes: 13

NSZombie
NSZombie

Reputation: 1867

In order to achieve what you want, you have to play with the camera. You'll have to update the pitch, heading, and altitude if needed.

Have a look here, you'll find everything : MKMapCamera Class Reference

Update : Unfortunately, you can't pitch maps who are satellite or hybrid.

If the map type is MKMapTypeSatellite or MKMapTypeHybrid, the pitch value is clamped to 0.

Upvotes: 1

Naughty_Ottsel
Naughty_Ottsel

Reputation: 1103

Found this in the MapKit Reference:

Reference Link

showsBuildings A Boolean indicating whether the map displays extruded building information.

Declaration SWIFT var showsBuildings: Bool OBJECTIVE-C @property(nonatomic) BOOL showsBuildings Discussion When this property is set to YES and the camera has a pitch angle greater than zero, the map extrudes buildings so that they extend above the map plane, creating a 3D effect. The mapType property must be set to MKMapTypeStandard for extruded buildings to be displayed. The default value of this property is YES.

Import Statement import MapKit

Availability Available in iOS 7.0 and later.

MKMapCameraClass:

pitch The viewing angle of the camera, measured in degrees.

Declaration SWIFT var pitch: CGFloat OBJECTIVE-C @property(nonatomic) CGFloat pitch Discussion A value of 0 results in a camera pointed straight down at the map. Angles greater than 0 result in a camera that is pitched toward the horizon by the specified number of degrees. If the map type is MKMapTypeSatellite or MKMapTypeHybrid, the pitch value is clamped to 0.

The value in this property may be clamped to a maximum value to maintain map readability. There is no fixed maximum value, though, because the actual maximum value is dependent on the current altitude of the camera.

Import Statement import MapKit

Availability Available in iOS 7.0 and later.

Upvotes: 2

Related Questions