Apple MapKit 3D flyover

試著忘記壹切 提交于 2019-12-31 08:42:29

问题


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?

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.

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:


回答1:


You can now use the new iOS 9 MKMapTypeSatelliteFlyover type.




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/27144508/apple-mapkit-3d-flyover

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!