liuyg
2021-06-22 0163b28ce3a2e0186b82e02fd8f98f8d9ee55340
widgets/LeftNavigationBar/Widget.js
@@ -218,7 +218,8 @@
                        id: d[k].id,
                        serviceName: d[k].serviceName,
                        alpha: 1,
                        checked: d[k].menuStatus
                                checked: d[k].menuStatus,
                                attList: d[k].attList
                     }
                     if (that[d[k].id]) {
@@ -226,24 +227,18 @@
                     }
                     if (d[k].serviceUrl && d[k].serviceUrl.length > 0 && d[k].serviceUrl.indexOf('.openrealspace') != -1) {
                        a.model = true
                                a.model = true;
                                a.lat = d[k].lat;
                                a.lon = d[k].lon;
                                a.height = d[k].height;
                                a.yawAngle = d[k].yawAngle;
                                a.pitchAngle = d[k].pitchAngle;
                                a.rollAngle = d[k].rollAngle;
                     }
                     if (d[k].name == '三维倾斜数据') {
                        a.model = true
                     }
                     if (a.model) {
                        if (that[a.id]) {
                           Cesium.when(that[a.id], function (layer) {
                              that.map.scene.layers.remove(layer[0].name)
                           })
                        }
                     }
                     b.push(a);
                     i++;
@@ -268,18 +263,6 @@
                     function deWeight() {
                        for (var j = 0; j < data[i].children.length; j++) {
                           if (data[i].children[j].checked == true) {
                              var small = data[i].children[j];
                              if (small.model) {
                                 that.map.scene.globe.depthTestAgainstTerrain = false;
                                 var host = that.returnStr(small.src).host;
                                 var scene = that.map.scene;
                                 var partOfUrl = that.returnStr(small.src).partOfUrl;
                                 //添加S3M图层服务
                                 that[small.id] = scene.open(host + partOfUrl);
                              }
                           }
                           if (data[i].children[j].title && data[i].children[j].title.indexOf(type) == -1) {
                              data[i].children.splice(j, 1);
                              deWeight();
@@ -291,10 +274,6 @@
                     }
                  }
               }
               deParentWeight()
@@ -329,6 +308,8 @@
                     data[i].checked = true
                  }
                        if (data[i].children && data[i].children.length > 0) {
                  for (var j = 0; j < data[i].children.length; j++) {
                     if (data[i].children[j].id == keyId) {
@@ -336,6 +317,9 @@
                     }
                  }
                        }
               }
            }
@@ -381,19 +365,19 @@
                  showLine: false, //是否开启连接线
                  oncheck: function (obj) {
                     var keyId = that.getUrlKeyId("serviceId");
                     if (obj.data.children && obj.data.children.length > 0) {
                        // 点击的父
                        if (obj.checked == true) {
                           if (obj.data.model) {
                                        that.map.scene.globe.depthTestAgainstTerrain = false;
                              obj.data.children.forEach(item => {
                                            Cesium.when(that[item.id], function (layer) {
                                                that.map.scene.layers.remove(layer[0].name)
                                            })
                                 var host = that.returnStr(item.src).host;
                                 var scene = that.map.scene;
                                 var partOfUrl = that.returnStr(item.src).partOfUrl;
@@ -401,30 +385,28 @@
                                 that[item.id] = scene.open(host + partOfUrl);
                                 //定位到场景
                                 Cesium.loadJson(host + partOfUrl + '/scenes.json').then(function (scenes) {
                                    // var sname = scenes[0].name;
                                    // Cesium.loadJson(host + partOfUrl + '/scenes/' + sname + '.json').then(function (jsonData) {
                                    //    var cameraPosition = jsonData.camera;
                                    //    var tilt = Cesium.Math.toRadians(cameraPosition.tilt - 90);
                                    //    Cesium.when(promise, function (layer) {
                                    //       //设置相机位置、视角,便于观察场景
                                    //       scene.camera.setView({
                                    //          destination: new Cesium.Cartesian3.fromDegrees(cameraPosition.longitude, cameraPosition.latitude, cameraPosition.altitude),
                                    //          orientation: {
                                    //             heading: cameraPosition.heading,
                                    //             pitch: tilt,
                                    //             roll: 0
                                    //          }
                                    //       });
                                    //       if (!scene.pickPositionSupported) {
                                    //          alert('不支持深度纹理,无法拾取位置!');
                                    //       }
                                    //    }, function (e) {
                                    //       if (widget._showRenderLoopErrors) {
                                    //          var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?';
                                    //          widget.showErrorPanel(title, undefined, e);
                                    //       }
                                    //    });
                                    // });
                                                var sname = scenes[0].name;
                                                Cesium.loadJson(host + partOfUrl + '/scenes/' + sname + '.json').then(function (jsonData) {
                                                    Cesium.when(that[item.id], function (layer) {
                                                        //设置相机位置、视角,便于观察场景
                                                        scene.camera.setView({
                                                            destination: new Cesium.Cartesian3.fromDegrees(Number(item.lon), Number(item.lat), Number(item.height)),
                                                            orientation: {
                                                                heading: Cesium.Math.toRadians(Number(item.yawAngle)),
                                                                pitch: Cesium.Math.toRadians(Number(item.pitchAngle)),
                                                                roll: Cesium.Math.toRadians(Number(item.rollAngle))
                                                            }
                                                        });
                                                        if (!scene.pickPositionSupported) {
                                                            alert('不支持深度纹理,无法拾取位置!');
                                                        }
                                                    }, function (e) {
                                                        if (widget._showRenderLoopErrors) {
                                                            var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?';
                                                            widget.showErrorPanel(title, undefined, e);
                                                        }
                                                    });
                                                });
                                 });
                              });
                           } else {
@@ -433,7 +415,13 @@
                                 if (that[item.id]) {
                                    that[item.id].show = true
                                                that[item.id].getViewableRectangle().then(function (rectangle) {
                                                    return that.map.camera.flyTo({
                                                        destination: rectangle
                                                    });
                                                });
                                    topic.publish('appendItem', 'Layermanagement', item, that[item.id]);
                                                topic.publish('addLayersLegends', 'legends', item);
                                 } else {
                                    $.ajax({
                                       url: item.src + '/maps.json',
@@ -446,15 +434,13 @@
                                             url: res[0].path,
                                          }));
                                          topic.publish('appendItem', 'Layermanagement', item, that[item.id]);
                                          that[item.id].alpha = item.alpha
                                          if (keyId && keyId != "") {
                                                        topic.publish('addLayersLegends', 'legends', item);
                                                        that[item.id].alpha = item.alpha;
                                             that[item.id].getViewableRectangle().then(function (rectangle) {
                                                return that.map.camera.flyTo({
                                                   destination: rectangle
                                                });
                                             });
                                          }
                                       }
                                    })
                                 }
@@ -479,6 +465,7 @@
                              obj.data.children.forEach(item => {
                                 if (that[item.id]) {
                                    topic.publish('removeItem', 'Layermanagement', item);
                                                topic.publish('removeLayersLegends', 'legends', item);
                                    that[item.id].show = false;
                                 }
                              });
@@ -490,52 +477,59 @@
                     } else {
                        // 点击的子
                        if (obj.checked == true) {
                           if (obj.data.model) {
                                        Cesium.when(that[obj.data.id], function (layer) {
                                            that.map.scene.layers.remove(layer[0].name)
                                        })
                              that.map.scene.globe.depthTestAgainstTerrain = false;
                              var host = that.returnStr(obj.data.src).host;
                              var scene = that.map.scene;
                              var partOfUrl = that.returnStr(obj.data.src).partOfUrl;
                              //添加S3M图层服务
                              that[obj.data.id] = scene.open(host + partOfUrl);
                              //定位到场景
                              Cesium.loadJson(host + partOfUrl + '/scenes.json').then(function (scenes) {
                                 // var sname = scenes[0].name;
                                 // Cesium.loadJson(host + partOfUrl + '/scenes/' + sname + '.json').then(function (jsonData) {
                                 //    var cameraPosition = jsonData.camera;
                                 //    var tilt = Cesium.Math.toRadians(cameraPosition.tilt - 90);
                                 //    Cesium.when(promise, function (layer) {
                                 //       //设置相机位置、视角,便于观察场景
                                 //       scene.camera.setView({
                                 //          destination: new Cesium.Cartesian3.fromDegrees(cameraPosition.longitude, cameraPosition.latitude, cameraPosition.altitude),
                                 //          orientation: {
                                 //             heading: cameraPosition.heading,
                                 //             pitch: tilt,
                                 //             roll: 0
                                 //          }
                                 //       });
                                 //       if (!scene.pickPositionSupported) {
                                 //          alert('不支持深度纹理,无法拾取位置!');
                                 //       }
                                 //    }, function (e) {
                                 //       if (widget._showRenderLoopErrors) {
                                 //          var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?';
                                 //          widget.showErrorPanel(title, undefined, e);
                                 //       }
                                 //    });
                                 // });
                                            var sname = scenes[0].name;
                                            Cesium.loadJson(host + partOfUrl + '/scenes/' + sname + '.json').then(function (jsonData) {
                                                Cesium.when(that[obj.data.id], function (layer) {
                                                    //设置相机位置、视角,便于观察场景
                                                    scene.camera.setView({
                                                        destination: new Cesium.Cartesian3.fromDegrees(Number(obj.data.lon), Number(obj.data.lat), Number(obj.data.height)),
                                                        orientation: {
                                                            heading: Cesium.Math.toRadians(Number(obj.data.yawAngle)),
                                                            pitch: Cesium.Math.toRadians(Number(obj.data.pitchAngle)),
                                                            roll: Cesium.Math.toRadians(Number(obj.data.rollAngle))
                                                        }
                                                    });
                                                    if (!scene.pickPositionSupported) {
                                                        alert('不支持深度纹理,无法拾取位置!');
                                                    }
                                                }, function (e) {
                                                    if (widget._showRenderLoopErrors) {
                                                        var title = '加载SCP失败,请检查网络连接状态或者url地址是否正确?';
                                                        widget.showErrorPanel(title, undefined, e);
                                                    }
                                                });
                                            });
                              });
                           } else {
                              if (that[obj.data.id]) {
                                 that[obj.data.id].show = true;
                                            that[obj.data.id].getViewableRectangle().then(function (rectangle) {
                                                return that.map.camera.flyTo({
                                                    destination: rectangle
                                                });
                                            });
                                 topic.publish('appendItem', 'Layermanagement', obj.data, that[obj.data.id]);
                                            topic.publish('addLayersLegends', 'legends', obj.data);
                              } else {
                                 $.ajax({
                                    url: obj.data.src + '/maps.json',
@@ -549,16 +543,15 @@
                                       }));
                                       topic.publish('appendItem', 'Layermanagement', obj.data, that[obj.data.id]);
                                                    topic.publish('addLayersLegends', 'legends', obj.data);
                                       that[obj.data.id].alpha = obj.data.alpha
                                       if (keyId && keyId != "") {
                                          that[obj.data.id].getViewableRectangle().then(function (rectangle) {
                                             return that.map.camera.flyTo({
                                                destination: rectangle
                                             });
                                          });
                                       }
                                    }
                                 })
                              }
@@ -579,6 +572,7 @@
                              if (that[obj.data.id]) {
                                 topic.publish('removeItem', 'Layermanagement', obj.data);
                                            topic.publish('removeLayersLegends', 'legends', obj.data);
                                 that[obj.data.id].show = false;
                              }