赞
踩
//相机高度小于10000
//console.log(that.viewer.camera.positionCartographic.height.toFixed(0),1234)
2、点不飘在空中的解决办法,获取该点得高度
//点击事件 let handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas); handler.setInputAction((event)=> { let cartesian = this.viewer.scene.pickPosition(event.position); let cartographic = Cesium.Cartographic.fromCartesian(cartesian); let lng = Cesium.Math.toDegrees(cartographic.longitude); // 经度 let lat = Cesium.Math.toDegrees(cartographic.latitude); // 纬度 let alt = cartographic.height; // 高度 let coordinate = { longitude: Number(lng.toFixed(6)), latitude: Number(lat.toFixed(6)), altitude: Number(alt.toFixed(2)) }; console.log(coordinate); }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
3、获取相机视角的值
// let handler = new Cesium.ScreenSpaceEventHandler(this.viewer.canvas);
// handler.setInputAction((click) => {
// var pick = this.viewer.scene.pick(click.position);
// console.log("pick", this.getCamera());
// }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
//将坐标转化为84坐标 get84Cood(positon) { let zb = Cesium.Cartographic.fromCartesian(positon); let lat = Cesium.Math.toDegrees(zb.latitude); let lon = Cesium.Math.toDegrees(zb.longitude); let height = zb.height; return { lon, lat, height, }; }, //获取相机参数 getCamera() { let p = this.get84Cood(this.viewer.camera.position); let position = [p.lon, p.lat, p.height]; return { position, heading: this.viewer.camera.heading, pitch: this.viewer.camera.pitch, roll: this.viewer.camera.roll, }; },
4、飞行
positionList: [ { longitude: 120.82563518176293, latitude: 28.70423608654453, height: 412.4324942136966, heading: 3.4458786294875487, pitch: -0.44212293097718325, roll: 6.283175766823213, duration: 3, }, { longitude: 120.82240513541223, latitude: 28.70443158078275, height: 173.75262039052794, heading: 3.4458786561348362, pitch: -0.442123110228803, roll: 6.283175704542723, duration: 3, }, { longitude: 120.8239473224087, latitude: 28.704510072075553, height: 212.3752740168831, heading: 3.4458786576463014, pitch: -0.44212312039616064, roll: 6.283175701010101, duration: 3, }, ], count:0,
flyEVent() { if(this.positionList.length < this.count + 1){ return } const position = this.positionList[this.count]; this.viewer.camera.flyTo({ destination: Cesium.Cartesian3.fromDegrees( position.longitude, position.latitude, position.height ), duration: 5, //飞行所用时间 //maximumHeight: 500, //飞行高峰时的最大高度。 //pitchAdjustHeight: 1500, //如果摄像机的飞行高于此值,请调整俯仰航向以降低俯仰,并将地球保持在视野中 orientation: { heading: position.heading, pitch: position.pitch, roll: position.roll, }, complete: () => { // 在相机移动完成后执行 console.log("已抵达北京天安门"); this.flyEVent(); }, easingFunction:Cesium.EasingFunction.LINEAR_NONE }); this.count++; },
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。