首页 / 浏览问题 / WebGIS / 问题详情
沿线飞行flyManager.readyPromise.then不生效
2EXP 2020年07月20日
onload(Cesium) {

      var toolbar = document.getElementById("toolbar");

      var viewer = new Cesium.Viewer("cesiumContainer");

      viewer.imageryLayers.addImageryProvider(

        new Cesium.BingMapsImageryProvider({

          url: "https://dev.virtualearth.net",

          mapStyle: Cesium.BingMapsStyle.AERIAL,

          key: URL_CONFIG.BING_MAP_KEY

        })

      );

      var scene = viewer.scene;

      scene.globe.depthTestAgainstTerrain = false;

      var camera = scene.camera;

      //添加S3M图层服务

      var promise = scene.open(URL_CONFIG.SCENE_NIAOCHAO);

      Cesium.when(promise, layers => {

        camera.setView({

          destination: Cesium.Cartesian3.fromDegrees(116.3801, 39.9874, 12.0),

          orientation: {

            heading: 6.260995919619558,

            pitch: 0,

            roll: 0

          }

        });

        var routes = new Cesium.RouteCollection(viewer.entities);

        //添加fpf飞行文件,fpf由SuperMap iDesktop生成

        var fpfUrl = "../utils/niaocao.fpf";

        routes.fromFile(fpfUrl);

        //初始化飞行管理

        flyManager = new Cesium.FlyManager({

          scene: scene,

          routes: routes

        });

        //注册站点到达事件

        flyManager.stopArrived.addEventListener(function(routeStop) {

          routeStop.waitTime = 1; // 在每个站点处停留1s

        });

        flyManager.readyPromise.then(() => {

          // 飞行路线就绪

          var currentRoute = flyManager.currentRoute;

          currentRoute.isLineVisible = true;

          currentRoute.isStopVisible = true;

          //生成飞行文件中的所有站点列表

          var allStops = flyManager.getAllRouteStops();

          console.log(allStops);

        });

      });

    },

1个回答

您好,我这里测试您的代码是没问题的。需要注意的是,我不知道您的飞行文件路径是否正确,我用的是示例代码自带的飞行路径。
1,545EXP 2020年07月20日

   路径是没有问题的啊  "../utils/niaocao.fpf"

您好,我这里测试您的代码是能够成功运行,并且能够沿线飞行的。请问您说的flyManager.readyPromise.then不生效具体是什么意思呢?

var allStops = flyManager.getAllRouteStops();

          console.log(allStops);

这个 生成飞行坐标点列表就打印不出来

您好,可以打印的。方便将您的数据和代码私信发给我吗


<?xml version="1.0" encoding="UTF-8"?>
<SceneRoute xmlns="http://www.supermap.com.cn/ugc60">
<route name="Route1_2" speed="50" showroutestop="false" showrouteline="false" altitudefree="false" headingfree="False" tiltfree="false" flycircle="True" alongline="True">
<style>
<geostyle3d>
<linecolor>RGBA(147,112,219,255)</linecolor>
<linewidth>20</linewidth>
</geostyle3d>
</style>
<routestop name="Stop2" speed="0" excluded="False" viewType="camera">
<camera>
<longitude>116.380116005574</longitude>
<latitude>39.987407826007498</latitude>
<altitude>12.146604751236699</altitude>
<heading>358.72864174283029</heading>
<tilt>78.517979432028199</tilt>
<altitudeMode>RelativeToGround</altitudeMode>
</camera>
<style>
<geostyle3d>
<icon/>
<markersize>4</markersize>
<markericonscale>1</markericonscale>
<markercolor>RGBA(1,1,1,1)</markercolor>
</geostyle3d>
</style>
<setting>
<turnTime>1.5</turnTime>
<turnSlowly>False</turnSlowly>
<stopPlayMode>StopPause</stopPlayMode>
<autoPlay>True</autoPlay>
<pauseTime>0</pauseTime>
<angularSpeed>60</angularSpeed>
</setting>
</routestop>
<routestop name="Stop3" speed="0" excluded="False" viewType="camera">
<camera>
<longitude>116.380000161457</longitude>
<latitude>39.992627668302703</latitude>
<altitude>11.9067202266306</altitude>
<heading>86.132604998062291</heading>
<tilt>85.049736615412499</tilt>
<altitudeMode>RelativeToGround</altitudeMode>
</camera>
<style>
<geostyle3d>
<icon/>
<markersize>4</markersize>
<markericonscale>1</markericonscale>
<markercolor>RGBA(1,1,1,1)</markercolor>
</geostyle3d>
</style>
<setting>
<turnTime>1.5</turnTime>
<turnSlowly>False</turnSlowly>
<stopPlayMode>StopPause</stopPlayMode>
<autoPlay>True</autoPlay>
<pauseTime>0</pauseTime>
<angularSpeed>60</angularSpeed>
</setting>
</routestop>
</route>
</SceneRoute>

您好,您的fpf文件是没有问题的,您将路径"../utils/niaocao.fpf"改为"./utils/niaocao.fpf"。
这个我是试过的,我现在是配合的vue开发
您好,在vue框架下您的飞行文件需要放在static目录下。

crying然后还需要在html里引用么

您好,是需要添加引用的。
昨天写着就去开会过需求了,如果你有vue的demo可以给我发一份么

您好,如何添加引用可以参考http://support.supermap.com.cn:8090/webgl/examples/component/examples.html#layer这里的demo

...