Cesium 定位偏移问题

  最近在做Cesium项目,客户想要初始化地图时候就有三维倾斜效果

  一开始采用的解决方案是使用camera的flyTo功能,设置pitch俯仰角度,结果发现设置pitch之后定位位置会出现偏移,基于偏移计算相机该放置位置过于复杂,后来发现可以使用viewer的flyTo功能

  var flyEntity = new Cesium.Entity({
                            id : 'flyTmp',
                            position : Cesium.Cartesian3.fromDegrees(flyPosition.x, flyPosition.y,1000) ,
                            point : {
                                pixelSize : 0.1,
                                color : Cesium.Color.WHITE.withAlpha(0),
                                outlineColor : Cesium.Color.WHITE.withAlpha(0),
                                outlineWidth : 1
                            }
                        });
                        viewer.entities.add(flyEntity);

                        viewer.flyTo(flyEntity,{
                            // maximumHeight:20,
                            offset: new Cesium.HeadingPitchRange(0.0, Cesium.Math.toRadians(-20.0))

                        })

PS:viewer 如果是flyTo entitycollection ,会自动计算定位到中心位置,但是高度设置貌似无用(此项有待考证);

                           flyTo entity ,根据entity设置的位置还是会有一定的偏移,基于实际情况做适当调整

posted @ 2020-05-29 14:30  t_b_Giser  阅读(4964)  评论(0)    收藏  举报