无法切换路线,它将切换的路线都加在一块飞行了
  play(id) {
      this.isplay = !this.isplay;
      let aaa = true;
      if (this.id == id) {
        aaa = false;
      } else {
        aaa = true;
        this.id = id;
      }
      if (!this.isplay) {
        //播放
        if (aaa) {
          let para = {
            parentId: id,
          };
          this.axios({
            method: "post",
            url: "/fzgh/tdPathNavigation/list",
            params: para,
          }).then((res) => {
            var viewList = [];
            res.data.forEach((item) => {
              viewList.push({
                x: Number(item.x),
                y: Number(item.y),
                z: Number(item.z),
                speed: Number(item.speed),
                roll: Number(item.roll),
                pitch: Number(item.pitch),
                heading: Number(item.heading),
                distance: Number(item.distance),
              });
            });
            let arrivedStopNum = 0;
            window.flyManager.stopArrived.addEventListener((routeStop) => {
              routeStop.waitTime = 0.1; //修改站点的停留时间
              arrivedStopNum += 1;
              if (arrivedStopNum === viewList.length - 1) {
                this.playEnd();
              }
            });
            window.flyManager.readyPromise.then(() => {
              var route = window.flyManager.currentRoute;
              route.isLineVisible = false;
              route.isStopVisible = false;
              // console.warn(this.arr, "第二次");
              console.log(this.arr.length);
              // if (this.arr.length > 0) {
              //   this.arr.forEach((routeStop) => {
              //     route.removeAllSites(routeStop);
              //   });
              //   // console.warn(this.arr, "第三次");
              // }
              // this.arr = [];
              console.warn(window.flyManager, "currentIndex ");
              // window.flyManager.currentIndex = 1; //飞行路线可以添加多个route,设置索引来加载不同的路线
              for (var k = 0; k < viewList.length; k++) {
                var position = Cesium.Cartesian3.fromDegrees(
                  viewList[k].x,
                  viewList[k].y,
                  viewList[k].z
                );
                var routeStop = new Cesium.RouteStop({
                  point: position,
                  heading: viewList[k].heading,
                  tilt: Cesium.Math.toRadians(viewList[k].pitch),
                  stopName: "站" + k,
                  speed: viewList[k].speed,
                  waitTime: 1,
                });
               
                route.addStop(routeStop);
                this.arr.push(routeStop);
              }
              console.warn(route, "routeStop");
              viewList = [];
              // console.warn(this.arr, "第一次");
            });
            window.flyManager && window.flyManager.play();
          });
        } else {
          window.flyManager && window.flyManager.play();
        }
      } else {
        window.flyManager && window.flyManager.pause();
      }
    },
fpf文件
<?xml version="1.0" encoding="UTF-8"?>
<SceneRoute xmlns="
http://www.supermap.com.cn/ugc60">
<route name="飞行路线_3" speed="100" lineType="0" showroutestop="False" showrouteline="False" altitudefree="False" headingfree="False" tiltfree="False" flycircle="False" alongline="False">
<style>
<geostyle3d>
<linecolor>RGBA(147,112,219,255)</linecolor>
<linewidth>2</linewidth>
<altitudeMode>Absolute</altitudeMode>
<bottomAltitude>0.00</bottomAltitude>
</geostyle3d>
</style>
</route>
</SceneRoute>
删掉了默认的加载点了