Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/96.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios MGLUserLocationAnnotationView子类不获取摄影机的俯仰透视图_Ios_Annotations_Mapbox_Mapbox Ios_Mapbox Ios Maps - Fatal编程技术网

Ios MGLUserLocationAnnotationView子类不获取摄影机的俯仰透视图

Ios MGLUserLocationAnnotationView子类不获取摄影机的俯仰透视图,ios,annotations,mapbox,mapbox-ios,mapbox-ios-maps,Ios,Annotations,Mapbox,Mapbox Ios,Mapbox Ios Maps,我已经根据以下文档设置了用户位置图标的样式: 它可以工作,但尽管我使用了摄影机和音高,但它是以二维显示的。我怎样才能使它在相机的正确视角下,并且俯仰效果有效 我用以下代码添加了MGLMapCamera: func mapViewDidFinishLoadingMap(_ mapView: MGLMapView) { // Wait for the map to load before initiating the first camera movement. m

我已经根据以下文档设置了用户位置图标的样式:

它可以工作,但尽管我使用了摄影机和音高,但它是以二维显示的。我怎样才能使它在相机的正确视角下,并且俯仰效果有效

我用以下代码添加了MGLMapCamera:

func mapViewDidFinishLoadingMap(_ mapView: MGLMapView) {
       // Wait for the map to load before initiating the first camera movement.

       mapView.camera = MGLMapCamera(lookingAtCenter: mapView.centerCoordinate, altitude: 200, pitch: 50, heading: 0)
              
}
安卓难道没有像gps那样的摄像头模式吗?

如果希望注释视图与地图视图倾斜,可以使用该属性。这将确定在倾斜地图上,注释视图是否随着视点和注释视图之间的距离的变化而增大或减小

当此属性的值为“是”且地图倾斜时,如果注释视图朝向视图顶部(更接近地平线),注释视图会显示得更小,如果朝向视图底部(更接近视点),注释视图会显示得更大。

我找到了一个解决方案

据我所知,没有办法设置一个选项。所以我手动解决了这个问题:

首先,我创建一个图像:

private func setupLayers() {

     if arrow == nil {
           arrow = CALayer()
           let myImage = UIImage(named: "arrow")?.cgImage
           arrow.bounds = CGRect(x: 0, y: 0, width: size, height: size)
           
           arrow.contents = myImage
        
           layer.addSublayer(arrow)
     }
}
然后,我使用MGLRadiansFromDegrees将弧度转换为度,并在每次更新时变换图像:

override func update() {
       // Convert Optional to Double
       let camerapitch = Double(mapView?.camera.pitch ?? 0)
        
       let pitch: CGFloat = MGLRadiansFromDegrees(camerapitch)
        
       layer.transform = CATransform3DMakeRotation(pitch, 1, 0, 0)
}

我无法发表评论(声誉太低),但我想我还是会问你:你的图标音高对齐设置为什么?另见:谢谢你的回答。我如何在上面的示例中实现这一点?没有MGLSymbolStyleLayer。谢谢您的回答。我试过了,但这不是我的意思。我想让图标/箭头拍摄相机的透视图。尤其是音高。在您的示例中,仅更改图标的大小。