使用Mapbox非常新,并且在设置mapView的音高/方位时遇到了麻烦。是否有类似的东西:
mapView.setPitch = 45
非常感谢任何帮助!
答案 0 :(得分:1)
音高是MGLMapCamera
类的一部分。
见
此示例代码段
/**
Pitch toward the horizon measured in degrees, with 0 degrees resulting in a
two-dimensional map.
*/
func togglePitch(sender: UISwitch) {
let camera = mapView!.camera
camera.pitch = sender.on ? 60 : 0
mapView!.setCamera(camera, animated: false)
}
答案 1 :(得分:1)
这是你可以做到的一种方式。
//Create a new MKMapCamera object
var newCameraPosition = MGLMapCamera(lookingAtCenterCoordinate: mapView.centerCoordinate, fromDistance: mapView.camera.altitude + 1600, pitch: 50, heading: -30)
// Then you could call it like this
mapView.camera = newCameraPosition
但是让我详细说明设置。
@IBOutlet weak var mapView: MGLMapView!
let distance: CLLocationDistance = 500
let pitch: CGFloat = 35
let heading = 45.0
var camera = MGLMapCamera()
let coordinate = CLLocationCoordinate2D(latitude: 49.7484405,
longitude: -132.9856644)
override func viewDidLoad() {
super.viewDidLoad()
mapView.mapType = .Standard
camera = MGLMapCamera(lookingAtCenterCoordinate: coordinate,
fromDistance: distance,
pitch: 0,
heading: 0)
self.mapView.camera = camera
}