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 layerJson = ref<any>([]);
const clearBool = ref(true);
const initGraphicLength = ref(0);
let map: any = props.mapInstance;
let graphicLayer: any = props.graphicInstance;
let dataIndex = 0 as any;
@ -156,6 +157,7 @@ const getConfig = async () => {
layerJson.value = JSON.parse(result.configValue);
console.log(layerJson.value);
if (layerJson.value.length > 0) {
initGraphicLength.value = layerJson.value.length;
layerJson.value.map((item: any, index: number) => {
if (item.type == "fixedRoute") {
const obj = {
@ -340,8 +342,14 @@ const closeDiv = () => {
};
onUnmounted(() => {
map = null;
if (clearBool) {
graphicLayer.clear();
if (clearBool.value) {
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>

View File

@ -178,6 +178,7 @@ const viewParams = ref({
});
const infoShow = ref(false);
const clearBool = ref(true);
const initGraphicLength = ref(0);
let map: any = props.mapInstance;
let graphicLayer: any = props.graphicInstance;
onMounted(() => {});
@ -187,6 +188,8 @@ const saveJson = async () => {
// ElMessage("");
// return;
// }
initGraphicLength.value = graphicLayer.getGraphics().length;
clearBool.value = false;
emits("saveJson", graphicLayer);
};
@ -470,8 +473,14 @@ const closeDiv = () => {
};
onUnmounted(() => {
map = null;
if (clearBool) {
graphicLayer.clear();
if (clearBool.value) {
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>

View File

@ -49,13 +49,18 @@ const tableData = ref<any>([]);
const checkVal = ref(false);
const layerJson = ref<any>([]);
const clearBool = ref(true);
const initGraphicLength = ref(0);
let map: any = props.mapInstance;
let graphicLayer: any = props.graphicInstance;
let dataIndex = 0;
onMounted(() => {
graphicLayer?.on(mars3d.EventType.drawCreated, function (event: any) {
console.log("矢量对象绘制完成", event);
productTableData();
tableData.value.push({
key: event.graphic.id,
name: getGraphicName(event.graphic)
});
});
bindLayerPopup(); // popup,
bindLayerContextMenu(); // ,
@ -72,6 +77,7 @@ const getConfig = async () => {
layerJson.value = JSON.parse(result.configValue);
console.log(layerJson.value);
if (layerJson.value.length > 0) {
initGraphicLength.value = layerJson.value.length;
layerJson.value.map((item: any, index: number) => {
if (item.type == "point") {
const graphic = item;
@ -122,34 +128,6 @@ const getGraphicName = (graphic: any) => {
graphic.name = `未命名${dataIndex}`;
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 = () => {
graphicLayer.bindContextMenu([
@ -254,8 +232,14 @@ const closeDiv = () => {
};
onUnmounted(() => {
map = null;
if (clearBool) {
graphicLayer.clear();
if (clearBool.value) {
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>

View File

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

View File

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

View File

@ -178,9 +178,12 @@ const viewParams = ref({
});
const infoShow = ref(false);
const clearBool = ref(true);
const initGraphicLength = ref(0);
let map: any = props.mapInstance;
let graphicLayer: any = props.graphicInstance;
onMounted(() => {});
onMounted(() => {
initGraphicLength.value = graphicLayer.getGraphics().length;
});
// JSON
const saveJson = async () => {
// if (graphicLayer.length == 0) {
@ -470,8 +473,14 @@ const closeDiv = () => {
};
onUnmounted(() => {
map = null;
if (clearBool) {
graphicLayer.clear();
if (clearBool.value) {
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>

View File

@ -49,13 +49,18 @@ const tableData = ref<any>([]);
const checkVal = ref(false);
const layerJson = ref<any>([]);
const clearBool = ref(true);
const initGraphicLength = ref(0);
let map: any = props.mapInstance;
let graphicLayer: any = props.graphicInstance;
let dataIndex = 0;
onMounted(() => {
graphicLayer?.on(mars3d.EventType.drawCreated, function (event: any) {
console.log("矢量对象绘制完成", event);
productTableData();
tableData.value.push({
key: event.graphic.id,
name: getGraphicName(event.graphic)
});
});
bindLayerPopup(); // popup,
bindLayerContextMenu(); // ,
@ -72,6 +77,7 @@ const getConfig = async () => {
layerJson.value = JSON.parse(result.configValue);
console.log(layerJson.value);
if (layerJson.value.length > 0) {
initGraphicLength.value = layerJson.value.length;
layerJson.value.map((item: any, index: number) => {
if (item.type == "point") {
const graphic = item;
@ -122,34 +128,6 @@ const getGraphicName = (graphic: any) => {
graphic.name = `未命名${dataIndex}`;
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 = () => {
graphicLayer.bindContextMenu([
@ -254,8 +232,14 @@ const closeDiv = () => {
};
onUnmounted(() => {
map = null;
if (clearBool) {
graphicLayer.clear();
if (clearBool.value) {
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>

View File

@ -3,7 +3,7 @@
<div class="map-content" id="map-content">
<div id="mars3dContainer" class="mars3d-container"></div>
<!-- 搜索框 -->
<div class="input-search" v-if="plusMenu.searchAble">
<div class="input-search">
<el-input
v-model="inputVal"
@blur="closeSearch"
@ -22,7 +22,7 @@
</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="toolbar-item" @click="showWidget(item.name)">
<img :src="item.icon" alt="" srcset="" style="width: 16px; height: 16px" />
@ -358,11 +358,6 @@ const props = {
};
//
const albugineaList = ref([]);
//
const plusMenu = ref({
searchAble: false,
menuAble: false
});
const hours = computed(() => Math.floor(sunProperty.value.currDate / 60));
const minutes = computed(() => Math.floor(sunProperty.value.currDate / 60));
let map: any;
@ -468,21 +463,7 @@ onMounted(async () => {
await initMars3d(configJson.value);
await initTree();
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) => {
if (arr && arr.length > 0) {
@ -536,6 +517,9 @@ const showMapData = (arr: any) => {
});
console.log(newRoutePath);
graphicLayer.addGraphic(newRoutePath);
//
newRoutePath.flyTo();
newRoutePath.start();
}
});
}