fix: BUG修改

This commit is contained in:
kun 2023-11-17 19:24:05 +08:00
parent 09e417e0a3
commit e346bec514
8 changed files with 81 additions and 92 deletions

View File

@ -139,6 +139,7 @@ const globalStore = GlobalStore();
const tableData = ref<any>([]); const tableData = ref<any>([]);
const layerJson = ref<any>([]); const layerJson = ref<any>([]);
const clearBool = ref(true); const clearBool = ref(true);
const initGraphicLength = ref(0);
let map: any = props.mapInstance; let map: any = props.mapInstance;
let graphicLayer: any = props.graphicInstance; let graphicLayer: any = props.graphicInstance;
let dataIndex = 0 as any; let dataIndex = 0 as any;
@ -156,6 +157,7 @@ const getConfig = async () => {
layerJson.value = JSON.parse(result.configValue); layerJson.value = JSON.parse(result.configValue);
console.log(layerJson.value); console.log(layerJson.value);
if (layerJson.value.length > 0) { if (layerJson.value.length > 0) {
initGraphicLength.value = layerJson.value.length;
layerJson.value.map((item: any, index: number) => { layerJson.value.map((item: any, index: number) => {
if (item.type == "fixedRoute") { if (item.type == "fixedRoute") {
const obj = { const obj = {
@ -340,8 +342,14 @@ const closeDiv = () => {
}; };
onUnmounted(() => { onUnmounted(() => {
map = null; map = null;
if (clearBool) { if (clearBool.value) {
graphicLayer.clear(); let arr = graphicLayer.getGraphics();
console.log(arr);
for (let i = arr.length - 1; i >= initGraphicLength.value; i--) {
const graphic = graphicLayer.getGraphicById(arr[i].id);
graphic && graphicLayer.removeGraphic(graphic);
}
// graphicLayer.clear();
} }
}); });
</script> </script>

View File

@ -178,6 +178,7 @@ const viewParams = ref({
}); });
const infoShow = ref(false); const infoShow = ref(false);
const clearBool = ref(true); const clearBool = ref(true);
const initGraphicLength = ref(0);
let map: any = props.mapInstance; let map: any = props.mapInstance;
let graphicLayer: any = props.graphicInstance; let graphicLayer: any = props.graphicInstance;
onMounted(() => {}); onMounted(() => {});
@ -187,6 +188,8 @@ const saveJson = async () => {
// ElMessage(""); // ElMessage("");
// return; // return;
// } // }
initGraphicLength.value = graphicLayer.getGraphics().length;
clearBool.value = false; clearBool.value = false;
emits("saveJson", graphicLayer); emits("saveJson", graphicLayer);
}; };
@ -470,8 +473,14 @@ const closeDiv = () => {
}; };
onUnmounted(() => { onUnmounted(() => {
map = null; map = null;
if (clearBool) { if (clearBool.value) {
graphicLayer.clear(); let arr = graphicLayer.getGraphics();
console.log(arr);
for (let i = arr.length - 1; i >= initGraphicLength.value; i--) {
const graphic = graphicLayer.getGraphicById(arr[i].id);
graphic && graphicLayer.removeGraphic(graphic);
}
// graphicLayer.clear();
} }
}); });
</script> </script>

View File

@ -49,13 +49,18 @@ const tableData = ref<any>([]);
const checkVal = ref(false); const checkVal = ref(false);
const layerJson = ref<any>([]); const layerJson = ref<any>([]);
const clearBool = ref(true); const clearBool = ref(true);
const initGraphicLength = ref(0);
let map: any = props.mapInstance; let map: any = props.mapInstance;
let graphicLayer: any = props.graphicInstance; let graphicLayer: any = props.graphicInstance;
let dataIndex = 0; let dataIndex = 0;
onMounted(() => { onMounted(() => {
graphicLayer?.on(mars3d.EventType.drawCreated, function (event: any) { graphicLayer?.on(mars3d.EventType.drawCreated, function (event: any) {
console.log("矢量对象绘制完成", event); console.log("矢量对象绘制完成", event);
productTableData();
tableData.value.push({
key: event.graphic.id,
name: getGraphicName(event.graphic)
});
}); });
bindLayerPopup(); // popup, bindLayerPopup(); // popup,
bindLayerContextMenu(); // , bindLayerContextMenu(); // ,
@ -72,6 +77,7 @@ const getConfig = async () => {
layerJson.value = JSON.parse(result.configValue); layerJson.value = JSON.parse(result.configValue);
console.log(layerJson.value); console.log(layerJson.value);
if (layerJson.value.length > 0) { if (layerJson.value.length > 0) {
initGraphicLength.value = layerJson.value.length;
layerJson.value.map((item: any, index: number) => { layerJson.value.map((item: any, index: number) => {
if (item.type == "point") { if (item.type == "point") {
const graphic = item; const graphic = item;
@ -122,34 +128,6 @@ const getGraphicName = (graphic: any) => {
graphic.name = `未命名${dataIndex}`; graphic.name = `未命名${dataIndex}`;
return `${graphic.type} - ${graphic.name}`; return `${graphic.type} - ${graphic.name}`;
}; };
//
const productTableData = () => {
console.log(graphicLayer.graphics);
const list = graphicLayer.graphics;
for (let i = list.length - 1; i >= 0; i--) {
const graphic = list[i];
if (graphic.isPrivate) {
continue;
}
tableData.value.push({
key: graphic.id,
name: getGraphicName(graphic)
});
}
// let position = [] as any;
// const graphic = new mars3d.graphic.PointEntity({
// position: position,
// style: {
// color: "#00ffff",
// pixelSize: 6,
// outlineColor: "#ffffff",
// outlineWidth: 2
// },
// attr: { index: dataIndex }
// });
// graphicLayer.addGraphic(graphic);
// dataIndex++;
};
// //
const bindLayerContextMenu = () => { const bindLayerContextMenu = () => {
graphicLayer.bindContextMenu([ graphicLayer.bindContextMenu([
@ -254,8 +232,14 @@ const closeDiv = () => {
}; };
onUnmounted(() => { onUnmounted(() => {
map = null; map = null;
if (clearBool) { if (clearBool.value) {
graphicLayer.clear(); let arr = graphicLayer.getGraphics();
console.log(arr);
for (let i = arr.length - 1; i >= initGraphicLength.value; i--) {
const graphic = graphicLayer.getGraphicById(arr[i].id);
graphic && graphicLayer.removeGraphic(graphic);
}
// graphicLayer.clear();
} }
}); });
</script> </script>

View File

@ -537,6 +537,9 @@ const showMapData = (arr: any) => {
}); });
console.log(newRoutePath); console.log(newRoutePath);
graphicLayer.addGraphic(newRoutePath); graphicLayer.addGraphic(newRoutePath);
//
newRoutePath.flyTo();
newRoutePath.start();
} }
}); });
} }

View File

@ -139,6 +139,7 @@ const globalStore = GlobalStore();
const tableData = ref<any>([]); const tableData = ref<any>([]);
const layerJson = ref<any>([]); const layerJson = ref<any>([]);
const clearBool = ref(true); const clearBool = ref(true);
const initGraphicLength = ref(0);
let map: any = props.mapInstance; let map: any = props.mapInstance;
let graphicLayer: any = props.graphicInstance; let graphicLayer: any = props.graphicInstance;
let dataIndex = 0 as any; let dataIndex = 0 as any;
@ -156,6 +157,7 @@ const getConfig = async () => {
layerJson.value = JSON.parse(result.configValue); layerJson.value = JSON.parse(result.configValue);
console.log(layerJson.value); console.log(layerJson.value);
if (layerJson.value.length > 0) { if (layerJson.value.length > 0) {
initGraphicLength.value = layerJson.value.length;
layerJson.value.map((item: any, index: number) => { layerJson.value.map((item: any, index: number) => {
if (item.type == "fixedRoute") { if (item.type == "fixedRoute") {
const obj = { const obj = {
@ -340,8 +342,14 @@ const closeDiv = () => {
}; };
onUnmounted(() => { onUnmounted(() => {
map = null; map = null;
if (clearBool) { if (clearBool.value) {
graphicLayer.clear(); let arr = graphicLayer.getGraphics();
console.log(arr);
for (let i = arr.length - 1; i >= initGraphicLength.value; i--) {
const graphic = graphicLayer.getGraphicById(arr[i].id);
graphic && graphicLayer.removeGraphic(graphic);
}
// graphicLayer.clear();
} }
}); });
</script> </script>

View File

@ -178,9 +178,12 @@ const viewParams = ref({
}); });
const infoShow = ref(false); const infoShow = ref(false);
const clearBool = ref(true); const clearBool = ref(true);
const initGraphicLength = ref(0);
let map: any = props.mapInstance; let map: any = props.mapInstance;
let graphicLayer: any = props.graphicInstance; let graphicLayer: any = props.graphicInstance;
onMounted(() => {}); onMounted(() => {
initGraphicLength.value = graphicLayer.getGraphics().length;
});
// JSON // JSON
const saveJson = async () => { const saveJson = async () => {
// if (graphicLayer.length == 0) { // if (graphicLayer.length == 0) {
@ -470,8 +473,14 @@ const closeDiv = () => {
}; };
onUnmounted(() => { onUnmounted(() => {
map = null; map = null;
if (clearBool) { if (clearBool.value) {
graphicLayer.clear(); let arr = graphicLayer.getGraphics();
console.log(arr);
for (let i = arr.length - 1; i >= initGraphicLength.value; i--) {
const graphic = graphicLayer.getGraphicById(arr[i].id);
graphic && graphicLayer.removeGraphic(graphic);
}
// graphicLayer.clear();
} }
}); });
</script> </script>

View File

@ -49,13 +49,18 @@ const tableData = ref<any>([]);
const checkVal = ref(false); const checkVal = ref(false);
const layerJson = ref<any>([]); const layerJson = ref<any>([]);
const clearBool = ref(true); const clearBool = ref(true);
const initGraphicLength = ref(0);
let map: any = props.mapInstance; let map: any = props.mapInstance;
let graphicLayer: any = props.graphicInstance; let graphicLayer: any = props.graphicInstance;
let dataIndex = 0; let dataIndex = 0;
onMounted(() => { onMounted(() => {
graphicLayer?.on(mars3d.EventType.drawCreated, function (event: any) { graphicLayer?.on(mars3d.EventType.drawCreated, function (event: any) {
console.log("矢量对象绘制完成", event); console.log("矢量对象绘制完成", event);
productTableData();
tableData.value.push({
key: event.graphic.id,
name: getGraphicName(event.graphic)
});
}); });
bindLayerPopup(); // popup, bindLayerPopup(); // popup,
bindLayerContextMenu(); // , bindLayerContextMenu(); // ,
@ -72,6 +77,7 @@ const getConfig = async () => {
layerJson.value = JSON.parse(result.configValue); layerJson.value = JSON.parse(result.configValue);
console.log(layerJson.value); console.log(layerJson.value);
if (layerJson.value.length > 0) { if (layerJson.value.length > 0) {
initGraphicLength.value = layerJson.value.length;
layerJson.value.map((item: any, index: number) => { layerJson.value.map((item: any, index: number) => {
if (item.type == "point") { if (item.type == "point") {
const graphic = item; const graphic = item;
@ -122,34 +128,6 @@ const getGraphicName = (graphic: any) => {
graphic.name = `未命名${dataIndex}`; graphic.name = `未命名${dataIndex}`;
return `${graphic.type} - ${graphic.name}`; return `${graphic.type} - ${graphic.name}`;
}; };
//
const productTableData = () => {
console.log(graphicLayer.graphics);
const list = graphicLayer.graphics;
for (let i = list.length - 1; i >= 0; i--) {
const graphic = list[i];
if (graphic.isPrivate) {
continue;
}
tableData.value.push({
key: graphic.id,
name: getGraphicName(graphic)
});
}
// let position = [] as any;
// const graphic = new mars3d.graphic.PointEntity({
// position: position,
// style: {
// color: "#00ffff",
// pixelSize: 6,
// outlineColor: "#ffffff",
// outlineWidth: 2
// },
// attr: { index: dataIndex }
// });
// graphicLayer.addGraphic(graphic);
// dataIndex++;
};
// //
const bindLayerContextMenu = () => { const bindLayerContextMenu = () => {
graphicLayer.bindContextMenu([ graphicLayer.bindContextMenu([
@ -254,8 +232,14 @@ const closeDiv = () => {
}; };
onUnmounted(() => { onUnmounted(() => {
map = null; map = null;
if (clearBool) { if (clearBool.value) {
graphicLayer.clear(); let arr = graphicLayer.getGraphics();
console.log(arr);
for (let i = arr.length - 1; i >= initGraphicLength.value; i--) {
const graphic = graphicLayer.getGraphicById(arr[i].id);
graphic && graphicLayer.removeGraphic(graphic);
}
// graphicLayer.clear();
} }
}); });
</script> </script>

View File

@ -3,7 +3,7 @@
<div class="map-content" id="map-content"> <div class="map-content" id="map-content">
<div id="mars3dContainer" class="mars3d-container"></div> <div id="mars3dContainer" class="mars3d-container"></div>
<!-- 搜索框 --> <!-- 搜索框 -->
<div class="input-search" v-if="plusMenu.searchAble"> <div class="input-search">
<el-input <el-input
v-model="inputVal" v-model="inputVal"
@blur="closeSearch" @blur="closeSearch"
@ -22,7 +22,7 @@
</div> </div>
</div> </div>
<!-- 菜单操作 --> <!-- 菜单操作 -->
<div class="menu-operate" v-if="plusMenu.menuAble"> <div class="menu-operate">
<div class="menu-operate-item" v-for="(item, i) in data" :key="i"> <div class="menu-operate-item" v-for="(item, i) in data" :key="i">
<div class="toolbar-item" @click="showWidget(item.name)"> <div class="toolbar-item" @click="showWidget(item.name)">
<img :src="item.icon" alt="" srcset="" style="width: 16px; height: 16px" /> <img :src="item.icon" alt="" srcset="" style="width: 16px; height: 16px" />
@ -358,11 +358,6 @@ const props = {
}; };
// //
const albugineaList = ref([]); const albugineaList = ref([]);
//
const plusMenu = ref({
searchAble: false,
menuAble: false
});
const hours = computed(() => Math.floor(sunProperty.value.currDate / 60)); const hours = computed(() => Math.floor(sunProperty.value.currDate / 60));
const minutes = computed(() => Math.floor(sunProperty.value.currDate / 60)); const minutes = computed(() => Math.floor(sunProperty.value.currDate / 60));
let map: any; let map: any;
@ -468,21 +463,7 @@ onMounted(async () => {
await initMars3d(configJson.value); await initMars3d(configJson.value);
await initTree(); await initTree();
await getConfig(); await getConfig();
await getPlusConfig();
}); });
//
const getPlusConfig = async () => {
let requestData = {
configKey: "plusConfig"
};
const { result } = await getSystemConfig(requestData);
console.log(result, "6666666");
if (result) {
let arr = JSON.parse(result.configValue);
plusMenu.value.searchAble = arr[0].value;
plusMenu.value.menuAble = arr[1].value;
}
};
// //
const showMapData = (arr: any) => { const showMapData = (arr: any) => {
if (arr && arr.length > 0) { if (arr && arr.length > 0) {
@ -536,6 +517,9 @@ const showMapData = (arr: any) => {
}); });
console.log(newRoutePath); console.log(newRoutePath);
graphicLayer.addGraphic(newRoutePath); graphicLayer.addGraphic(newRoutePath);
//
newRoutePath.flyTo();
newRoutePath.start();
} }
}); });
} }