关于cesium:超图iClient-webgl引擎场景定位问题

6次阅读

共计 787 个字符,预计需要花费 2 分钟才能阅读完成。

最近公司用到超图 iclient 引擎的能力,须要实现点击按钮定位到超图某个歪斜摄影场景的性能。超图官网提供的 API 只有创立实例时传递 autoSetView 主动定位到场景,代码如下:

// 萨尔茨堡服务地址
let url = "http://www.supermapol.com/realspace/services/3D-srsb/rest/realspace";
// 加载场景
const cbdPromise = scene.open(url, undefined, {autoSetView: true // 自定定位});

然而,如果想要加载模型是不定位,点击按钮后再定位 autoSetView 就无奈满足了。

通过一番摸索后,通过如下代码实现的性能:

// 加载场景
const cbdPromise = 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(longitude, latitude, altitude),
                  orientation: {heading: Cesium.Math.toRadians(heading),
                      pitch: Cesium.Math.toRadians(tilt - 90), roll: 0.0
                  }
              });
          });
    });
正文完
 0