From 094dff34cea6a27ff251b23fc30ffafff6d3bcf2 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Thu, 17 Jun 2021 11:32:15 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.0.105:10010/r/pyhmap
---
widgets/LeftNavigationBar/Widget.js | 206 +++++++++++++++++++++++++++++++++++++-------------
1 files changed, 151 insertions(+), 55 deletions(-)
diff --git a/widgets/LeftNavigationBar/Widget.js b/widgets/LeftNavigationBar/Widget.js
index e0dcc05..f820ae3 100644
--- a/widgets/LeftNavigationBar/Widget.js
+++ b/widgets/LeftNavigationBar/Widget.js
@@ -37,7 +37,7 @@
$('.left-navigation-bar-but').click(() => {
this.changeImg = !this.changeImg;
if (this.changeImg) {
- $('.l-n-b-b-img').attr("src", "../../images/addL/xzuo.png"); //打开
+ $('.l-n-b-b-img').attr("src", "./images/addL/xzuo.png"); //打开
$('.jimu-widget-LeftNavigationBar').css({
'left': '0px'
});
@@ -45,7 +45,7 @@
'left': '260px'
});
} else {
- $('.l-n-b-b-img').attr("src", "../../images/addL/xyou.png"); //关闭
+ $('.l-n-b-b-img').attr("src", "./images/addL/xyou.png"); //关闭
$('.jimu-widget-LeftNavigationBar').css({
'left': '-250px'
});
@@ -121,7 +121,7 @@
if (d[k].who == 'father') {
that.father = d[k].id;
}
- if (d[k].title.indexOf(val) != -1) { //选中id
+ if (d[k].title && d[k].title.indexOf(val) != -1) { //选中id
a = '' + d[k].id;
// var b = a.split('');
// for (var i in b) {
@@ -134,11 +134,12 @@
})
// }
}
- if (d[k].children) {
+ if (d[k].children && d[k].children.length > 0) {
useit(d[k].children);
}
}
};
+
that.changeData(that.dataAllArray, val); //重写数据
layui.use('tree', function () {
layui.tree.reload('demoId1', {
@@ -230,7 +231,11 @@
checked: d[k].menuStatus
}
- if (d[k].serviceUrl.indexOf('.openrealspace') != -1) {
+ if (that[d[k].id]) {
+ a.alpha = that[d[k].id].alpha
+ }
+
+ if (d[k].serviceUrl && d[k].serviceUrl.length > 0 && d[k].serviceUrl.indexOf('.openrealspace') != -1) {
a.model = true
}
@@ -246,17 +251,11 @@
})
}
- } else {
-
- if (that[a.id]) {
- that.map.imageryLayers.remove(that[a.id]);
- }
-
}
b.push(a);
i++;
- if (d[k].children.length != 0) {
+ if (d[k].children && d[k].children.length > 0) {
b[k].children = [];
b[k].who = 'father';
inits(d[k].children, b[k].children)
@@ -265,18 +264,6 @@
};
inits(val, data);
-
- // var i = 0,
- // ccinit = (a) => {
- // i++;
- // for (let k in a) {
- // if (a[k].children) {
- // a[k].who = i;
- // ccinit(a[k].children)
- // }
- // }
- // };
- // ccinit(this.data);
if (type != '') {
@@ -288,12 +275,47 @@
function deWeight() {
for (var j = 0; j < data[i].children.length; j++) {
- if (data[i].children[j].title.indexOf(type) == -1) {
+
+ 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);
+ } else {
+
+ if (that[small.id]) {
+ that[small.id].show = true
+ } else {
+ $.ajax({
+ url: small.src + '/maps.json',
+ type: 'get',
+ dataType: 'JSON',
+ success: function (res) {
+
+ that[small.id] = that.map.imageryLayers.addImageryProvider(new Cesium.SuperMapImageryProvider({
+ url: res[0].path,
+ }));
+ that[small.id].alpha = small.alpha
+
+ }
+ })
+ }
+
+
+ }
+ }
+
+ if (data[i].children[j].title && data[i].children[j].title.indexOf(type) == -1) {
data[i].children.splice(j, 1);
deWeight();
break;
}
+
}
}
@@ -325,6 +347,25 @@
}
}
+ }
+
+ var keyId = this.getUrlKeyId("serviceId");
+
+ if (keyId && keyId != "") {
+ for (var i = 0; i < data.length; i++) {
+
+ if (data[i].id == keyId) {
+ data[i].checked = true
+ }
+
+ for (var j = 0; j < data[i].children.length; j++) {
+
+ if (data[i].children[j].id == keyId) {
+ data[i].children[j].checked = true
+ }
+
+ }
+ }
}
@@ -368,9 +409,8 @@
},
showLine: false, //是否开启连接线
oncheck: function (obj) {
- // console.log(obj.data.id, '--', obj.checked, obj); //得到当前点击的节点数据
- // console.log(obj.checked); //得到当前节点的展开状态:open、close、normal
- // console.log(obj.elem); //得到当前节点元素
+
+ var keyId = that.getUrlKeyId("serviceId");
if (obj.data.children && obj.data.children.length > 0) {
@@ -417,20 +457,35 @@
});
});
} else {
- obj.data.children.forEach(item => {
- $.ajax({
- url: item.src + '/maps.json',
- type: 'get',
- dataType: 'JSON',
- success: function (res) {
- that[item.id] = that.map.imageryLayers.addImageryProvider(new Cesium.SuperMapImageryProvider({
- url: res[0].path,
- }));
- that[item.id].alpha = item.alpha
- }
- })
+ obj.data.children.forEach(item => {
+
+ if (that[item.id]) {
+ that[item.id].show = true
+ } else {
+ $.ajax({
+ url: item.src + '/maps.json',
+ type: 'get',
+ dataType: 'JSON',
+ success: function (res) {
+
+ that[item.id] = that.map.imageryLayers.addImageryProvider(new Cesium.SuperMapImageryProvider({
+ url: res[0].path,
+ }));
+ that[item.id].alpha = item.alpha
+
+ if (keyId && keyId != "") {
+ that[item.id].getViewableRectangle().then(function (rectangle) {
+ return that.map.camera.flyTo({
+ destination: rectangle
+ });
+ });
+ }
+ }
+ })
+ }
});
+
}
@@ -448,7 +503,7 @@
});
} else {
obj.data.children.forEach(item => {
- if (that[item.id]) that.map.imageryLayers.remove(that[item.id]);
+ if (that[item.id]) that[item.id].show = false
});
}
@@ -501,18 +556,33 @@
} else {
- $.ajax({
- url: obj.data.src + '/maps.json',
- type: 'get',
- dataType: 'JSON',
- success: function (res) {
+ if (that[obj.data.id]) {
+ that[obj.data.id].show = true
+ } else {
+ $.ajax({
+ url: obj.data.src + '/maps.json',
+ type: 'get',
+ dataType: 'JSON',
+ success: function (res) {
+
+ that[obj.data.id] = that.map.imageryLayers.addImageryProvider(new Cesium.SuperMapImageryProvider({
+ url: res[0].path,
+ }));
+ 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
+ });
+ });
+ }
+ console.log(that[obj.data.id])
+ }
+ })
+ }
- that[obj.data.id] = that.map.imageryLayers.addImageryProvider(new Cesium.SuperMapImageryProvider({
- url: res[0].path,
- }));
- that[obj.data.id].alpha = obj.data.alpha
- }
- })
+
}
@@ -525,7 +595,8 @@
})
} else {
- that.map.imageryLayers.remove(that[obj.data.id]);
+
+ if (that[obj.data.id]) that[obj.data.id].show = false
}
@@ -533,6 +604,27 @@
}
+
+ }
+
+ for (var i = 0; i < that.dataAllArray.length; i++) {
+
+ if (obj.data.id == that.dataAllArray[i].id) {
+ that.dataAllArray[i].menuStatus = 1;
+ break
+ }
+
+ if (that.dataAllArray[i].children && that.dataAllArray[i].children.length > 0) {
+
+ for (var j = 0; j < that.dataAllArray[i].children.length; j++) {
+
+ if (obj.data.id == that.dataAllArray[i].children[j].id) {
+ that.dataAllArray[i].children[j].menuStatus = 1;
+ break
+ }
+
+ }
+ }
}
},
@@ -546,8 +638,6 @@
if (type == 'add') {
$(".jimu-widget-LeftNavigationBar .tree-layer-opcity ul").empty();
-
- // console.log(type, data, elem, depId, parentId)
if (data.children) {
@@ -962,6 +1052,12 @@
}]
}],
}],
+ getUrlKeyId: function (name) {
+ var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
+ var r = window.location.search.substr(1).match(reg);
+ if (r != null) return decodeURI(r[2]);
+ return null;
+ },
destroy: function () {
//销毁的时候触发
//todo
--
Gitblit v1.9.3