当前位置: 首页 > Web前端 > JavaScript

SuperMapiClientwebgl引擎场景定位问题

时间:2023-03-27 01:52:52 JavaScript

最近公司使用了SuperMapiClient引擎的能力,需要实现SuperMap的某个倾斜摄影场景点击按钮定位的功能。SuperMap官方提供的API只是在创建实例时通过autoSetView自动定位场景。代码如下://萨尔茨堡服务地址leturl="http://www.supermapol.com/realspace/services/3D-srsb/rest/realspace";//加载场景constcbdPromise=scene.open(url,undefined,{autoSetView:true//自定义定位});但是,如果你想加载没有定位的模型,点击按钮然后定位autoSetView是不够的。经过一番摸索,该功能通过以下代码实现://加载场景constcbdPromise=scene.open(url,undefined,{autoSetView:false//关闭自动定位});//请求场景列表axios.get(`${url}/scenes.json`).then(([{path}])=>{//请求场景列表中第一个场景的摄像头信息并定位.如果有多个场景需要加载,计算多个场景的边界,然后定位。axios.get(`${path}.json`).then(({camera:{altitude,heading,latitude,longitude,tilt}})=>{scene.camera.setView({destination:Cesium.Cartesian3.fromDegrees(经度、纬度、高度),方向:{heading:Cesium.Math.toRadians(heading),pitch:Cesium.Math.toRadians(tilt-90),roll:0.0}});});});