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

最近公司用到超图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
                  }
              });
          });
    });

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理