|
@@ -93,10 +93,10 @@
|
|
|
type="text"
|
|
|
icon="el-icon-location"
|
|
|
@click="locateEvent(node)"
|
|
|
- style="position: absolute; right: -30px; top: -12px;"
|
|
|
+ style="position: absolute; right: -30px; top: -12px"
|
|
|
></el-button
|
|
|
></span>
|
|
|
- <span style="position: absolute;right: -85px;top: -8px;">
|
|
|
+ <span style="position: absolute; right: -85px; top: -8px">
|
|
|
<el-button
|
|
|
v-if="node.parent.label === '我的模型'"
|
|
|
size="small"
|
|
@@ -262,12 +262,10 @@ export default {
|
|
|
// 我的模型相关数据
|
|
|
myModel: null,
|
|
|
filterText: "",
|
|
|
- // 存储所有图层的node id
|
|
|
- treeIdMap: new Map(),
|
|
|
+ // 存放对应图层的坐标
|
|
|
+ treeCoordMap: new Map(),
|
|
|
isLeftLock: true,
|
|
|
isRightLock: true,
|
|
|
- // firstPolygon: null,
|
|
|
- // coordinates: null,
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -288,10 +286,10 @@ export default {
|
|
|
getLeftMenuTitle: {
|
|
|
handler(val) {
|
|
|
this.$nextTick(() => {
|
|
|
- if (this.treeIdMap.has(val)) {
|
|
|
+ if (treeIdMap.has(val)) {
|
|
|
console.log(val, "678");
|
|
|
// 设置默认勾选项
|
|
|
- this.$refs.tree.setCheckedKeys([this.treeIdMap.get(val)]);
|
|
|
+ this.$refs.tree.setCheckedKeys([treeIdMap.get(val)]);
|
|
|
// this.$store.state.mapMethodsCollection
|
|
|
// .get("RENDER")
|
|
|
// .setView(coordinates, 16);
|
|
@@ -324,7 +322,7 @@ export default {
|
|
|
if (myModelRef.label === "我的模型") {
|
|
|
this.$refs.tree.data[2].children = val.map((ele) => {
|
|
|
let firstId = publicFun.buildGuid();
|
|
|
- this.treeIdMap.set(ele.name, firstId);
|
|
|
+ treeIdMap.set(ele.name, firstId);
|
|
|
return {
|
|
|
id: firstId,
|
|
|
label: ele.name,
|
|
@@ -345,7 +343,7 @@ export default {
|
|
|
// }
|
|
|
getMyLabelData: {
|
|
|
handler(val) {
|
|
|
- console.log(val, "获取我的疑点数组");
|
|
|
+ // console.log(val, "获取我的疑点数组");
|
|
|
if (val.length > 0) {
|
|
|
console.log("获取的我的疑点数据");
|
|
|
this.rightLabelData = val.map((v, i) => {
|
|
@@ -370,17 +368,17 @@ export default {
|
|
|
if (item1.type === "我的模型") {
|
|
|
this.myModel = item1;
|
|
|
}
|
|
|
- this.treeIdMap.set(item1.type, item1.id);
|
|
|
+ treeIdMap.set(item1.type, item1.id);
|
|
|
return {
|
|
|
id: item1.id,
|
|
|
label: item1.type,
|
|
|
children: item1.children.map((item2) => {
|
|
|
- this.treeIdMap.set(item2.type, item2.id);
|
|
|
+ treeIdMap.set(item2.type, item2.id);
|
|
|
return {
|
|
|
id: item2.id,
|
|
|
label: item2.type,
|
|
|
children: item2.children.map((item3) => {
|
|
|
- this.treeIdMap.set(item3.type, item3.id);
|
|
|
+ treeIdMap.set(item3.type, item3.id);
|
|
|
this.rightPanelDataMap.set(item3.type, item3.children);
|
|
|
return {
|
|
|
id: item3.id,
|
|
@@ -393,8 +391,6 @@ export default {
|
|
|
}),
|
|
|
};
|
|
|
});
|
|
|
-
|
|
|
- // console.log(this.treeIdMap, "treeIdMap");
|
|
|
},
|
|
|
|
|
|
mounted() {
|
|
@@ -409,28 +405,11 @@ export default {
|
|
|
this.rightBoxBtn = true;
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- // console.log(
|
|
|
- // map2DViewer.groups["district_polygon"],
|
|
|
- // "检测是否存在地区图层group"
|
|
|
- // );
|
|
|
-
|
|
|
- // if (map2DViewer.groups["district_polygon"]) {
|
|
|
- // map2DViewer.groups["district_polygon"].remove();
|
|
|
- // map2DViewer.groups["district_label"].remove();
|
|
|
- // }
|
|
|
- // 不显示区域图
|
|
|
- // if (map2DViewer.groups["district_polygon"].remove()) {
|
|
|
- // map2DViewer.groups["district_polygon"].remove();
|
|
|
- // map2DViewer.groups["district_label"].remove();
|
|
|
- // }
|
|
|
},
|
|
|
beforeDestroy() {
|
|
|
- // 销毁前清空存放tree ID 的map
|
|
|
- this.treeIdMap.clear();
|
|
|
+ treeIdMap.clear();
|
|
|
+ this.treeCoordMap.clear();
|
|
|
map2DViewer.map.off("move");
|
|
|
- // map2DViewer.groups["district_polygon"].addTo(map2DViewer.map);
|
|
|
- // map2DViewer.groups["district_label"].addTo(map2DViewer.map);
|
|
|
},
|
|
|
methods: {
|
|
|
// 回退事件
|
|
@@ -473,7 +452,12 @@ export default {
|
|
|
return data.label.indexOf(value) !== -1;
|
|
|
},
|
|
|
locateEvent(node) {
|
|
|
- console.log(node, "目前的节点");
|
|
|
+ // console.log(node, "目前的节点");
|
|
|
+ if (this.treeCoordMap.has(node.data.label)) {
|
|
|
+ this.$store.state.mapMethodsCollection
|
|
|
+ .get("RENDER")
|
|
|
+ .setView(this.treeCoordMap.get(node.data.label), 16);
|
|
|
+ }
|
|
|
},
|
|
|
handleUpdate(node) {
|
|
|
// console.log(node.data.data, "涉及的图层");
|
|
@@ -499,9 +483,16 @@ export default {
|
|
|
// 渲染当前模块下的面图层
|
|
|
let cid = defaultLayers[data.label].cid;
|
|
|
let color = defaultLayers[data.label].color;
|
|
|
+
|
|
|
+ let passData = {
|
|
|
+ name: data.label,
|
|
|
+ value: cid,
|
|
|
+ };
|
|
|
+
|
|
|
+ // 存放当前选中的图层,方便关联自定义模型
|
|
|
+ this.$store.commit("changeTreeData", passData);
|
|
|
get(`./static/json/${cid}.json`).then((geoJson) => {
|
|
|
map2DViewer.polygons[`${cid}_layer`] = [];
|
|
|
-
|
|
|
this.originalData[data.label] = geoJson.map((v, index) => {
|
|
|
return {
|
|
|
id: publicFun.buildGuid("abnormal"),
|
|
@@ -510,25 +501,37 @@ export default {
|
|
|
properties: v.properties,
|
|
|
};
|
|
|
});
|
|
|
- console.log(this.originalData[data.label], "label");
|
|
|
+ // console.log(this.originalData[data.label], "label");
|
|
|
|
|
|
this.activeNames = ["myLabel", data.label];
|
|
|
|
|
|
// 地图定位
|
|
|
let firstPolygon = JSON.parse(JSON.stringify(geoJson[0]));
|
|
|
let coordinates = firstPolygon.geometry.coordinates[0][0][0];
|
|
|
- this.$store.state.mapMethodsCollection
|
|
|
- .get("RENDER")
|
|
|
- .setView(coordinates, 16);
|
|
|
+ this.treeCoordMap.set(data.label, coordinates);
|
|
|
+ // this.$store.state.mapMethodsCollection
|
|
|
+ // .get("RENDER")
|
|
|
+ // .setView(coordinates, 16);
|
|
|
|
|
|
this.$store.state.mapMethodsCollection
|
|
|
.get("RENDER")
|
|
|
.addPolygonLayer(geoJson, cid, color);
|
|
|
});
|
|
|
+ } else {
|
|
|
+ let passData = {
|
|
|
+ name: data.label,
|
|
|
+ value: data.label,
|
|
|
+ };
|
|
|
+ // 存放当前选中的图层,方便关联自定义模型
|
|
|
+ this.$store.commit("changeTreeData", passData);
|
|
|
}
|
|
|
} else {
|
|
|
// 设置右侧折叠面板item数量
|
|
|
delete this.originalData[data.label];
|
|
|
+ //关联自定义模型
|
|
|
+ this.$store.state.treeDataCollection.delete(data.label);
|
|
|
+ console.log(this.$store.state.treeDataCollection, "treeDataCollection");
|
|
|
+
|
|
|
// 只激活我的标记
|
|
|
this.activeNames = ["myLabel"];
|
|
|
|