Browse Source

添加地图元素显隐组件

master
Fuyuu 12 months ago
parent
commit
41242a56cf
  1. 22
      src/components/earthMap/AISInfoWindow.vue
  2. 158
      src/components/earthMap/ShowHideControl.vue
  3. 29
      src/components/earthMap/Toolbar.vue
  4. 9
      src/components/earthMap/toolbar/AddRadarCom.vue
  5. 13
      src/components/earthMap/toolbar/AddWaveCom.vue
  6. 1
      src/utils/earthMap/earthObj.ts

22
src/components/earthMap/AISInfoWindow.vue

@ -2,7 +2,7 @@
* @Author: Fuyuu 1805498209@qq.com
* @Date: 2024-01-05 14:18:33
* @LastEditors: Fuyuu 1805498209@qq.com
* @LastEditTime: 2024-01-09 11:14:45
* @LastEditTime: 2024-01-12 17:55:17
* @FilePath: \dt-admin-pc-v2\src\components\earthMap\AISInfoWindow.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
@ -105,6 +105,7 @@
import { defineComponent, getCurrentInstance, ref, watch } from 'vue';
import Window from '@/components/earthMap/components/Window.vue';
import { useEarthMapStore } from '/@/store/modules/earthMap';
import $mitt from '@/utils/earthMap/mitt';
// store
const store = useEarthMapStore();
export default defineComponent({
@ -138,9 +139,10 @@
// guid
watch(
() => proxy.ship_guid,
(newVal, oldVal) => {
(newVal, _oldVal) => {
console.log(newVal);
},{immediate : true}
},
{ immediate: true }
);
//
@ -152,8 +154,22 @@
checked.value = e;
// 使show
trackData.show = e;
// 线
$mitt.emit('trackShowChange', e);
}
$mitt.on('trackAllChange', (e: boolean) => {
// 线
checked.value = e;
});
$mitt.on('shipAllChange', (e: boolean) => {
//
if (!e) {
cancel()
}
})
return {
checked,
cancel,

158
src/components/earthMap/ShowHideControl.vue

@ -0,0 +1,158 @@
<template>
<div class="showhideControl">
<a-dropdown :trigger="['click']">
<template #overlay>
<a-menu>
<a-menu-item key="1">
<label for="ship-switch" style="margin-top: 2px">船只模型</label>
<a-switch id="ship-switch" v-model:checked="shipShow" @change="changeShipShow" checked-children="显示" un-checked-children="隐藏" />
</a-menu-item>
<a-menu-item key="1">
<label for="track-switch" style="margin-top: 2px">船只轨迹</label>
<a-switch id="track-switch" v-model:checked="trackShow" @change="changeTrackShow" checked-children="显示" un-checked-children="隐藏" />
</a-menu-item>
</a-menu>
</template>
<a-button> 地图元素显隐 <CaretUpOutlined /></a-button>
</a-dropdown>
</div>
</template>
<script lang="ts">
import { defineComponent, ref, nextTick, watch } from 'vue';
import { CaretUpOutlined } from '@ant-design/icons-vue';
import $mitt from '@/utils/earthMap/mitt';
export default defineComponent({
setup() {
//
const shipShow = ref<boolean>(true);
//
const trackShow = ref<boolean>(true);
//
const shipList = ref([]);
//
const trackList = ref([]);
//
function getShipInfo() {
//
let earthMapElements = window.$earth.getAllObjects();
//
let earthMapShips = earthMapElements.filter((item) => item.name && item.name.includes('船'));
if (earthMapShips.length > 0) {
//
shipShow.value = earthMapShips.every((item) => item.show === true);
//
shipList.value = earthMapShips;
} else {
console.log('当前场景没有船只');
}
}
// 线
function getTrackInfo() {
//
let earthMapElements = window.$earth.getAllObjects();
//
let earthMapTracks = earthMapElements.filter((item) => item.name && item.name.includes('轨迹线'));
if (earthMapTracks.length > 0) {
//
trackShow.value = earthMapTracks.every((item) => item.show === true);
//
trackList.value = earthMapTracks;
} else {
console.log('当前场景没有轨迹线');
}
}
//
function changeShipShow(e) {
if (shipList.value.length > 0) {
if (!e) {
//
trackShow.value = false;
//
trackList.value.forEach((item: any) => {
item.show = false;
});
}
//
shipShow.value = e;
shipList.value.forEach((item: any) => {
//
item.show = e;
});
} else {
console.log('当前场景没有船只');
}
}
// 线
function changeTrackShow(e) {
if (trackList.value.length > 0) {
if (shipShow.value) {
//
trackShow.value = e;
trackList.value.forEach((item: any) => {
//
item.show = e;
});
} else {
trackShow.value = false;
console.log('请先打开显示船只模型');
}
} else {
console.log('当前场景没有船只');
}
}
// 线
watch(trackShow, (newValue, _oldValue) => {
// 线
$mitt.emit('trackAllChange', newValue);
});
//
watch(shipShow, (newValue, _oldValue) => {
// 线
$mitt.emit('shipAllChange', newValue);
});
// mqtt
$mitt.on('deviceCmd', () => {
nextTick(() => {
//
getShipInfo();
// 线
getTrackInfo();
});
});
// 线
$mitt.on('trackShowChange', (e: boolean) => {
if (!e) {
//
trackShow.value = e;
} else {
//
trackShow.value = window.$earth
.getAllObjects()
.filter((item) => item.name && item.name.includes('轨迹线'))
.every((item) => item.show === true);
}
});
return {
shipShow,
trackShow,
changeShipShow,
changeTrackShow,
};
},
components: {
CaretUpOutlined,
},
});
</script>
<style lang="less" scoped>
.showhideControl {
position: absolute;
left: 0;
bottom: 30px;
z-index: 99999;
}
</style>

29
src/components/earthMap/Toolbar.vue

@ -71,12 +71,12 @@
<div id="addPopModal" class="popModal" style="top: 355px">
<ul>
<p @click="openCreateModel('addModelWin')">添加模型</p>
<p @click="openCreateModel('roamPathList')">路径巡检</p>
<p @click="openCreateModel('keyControlAreaList')">管控区域</p>
<p @click="addArea()">添加区域</p>
<p @click="addRadar()">添加雷达</p>
<p @click="addMonitorPoint()">添加监控点</p>
<p @click="addWave()">添加微波探测</p>
<p @click="addRadar()">添加雷达</p>
<p @click="openCreateModel('roamPathList')">路径巡检</p>
<p @click="openCreateModel('keyControlAreaList')">管控区域</p>
</ul>
</div>
<div class="mapBox">
@ -1090,12 +1090,14 @@
function addArea() {
$mitt.emit('drawShapeShow', { show: true, title: '区域创建工具', from: 'addArea' });
$mitt.on('addAreaFinished', (t: any) => {
console.log('addAreaFinished', t);
// console.log('addAreaFinished', t);
//t drawShape
t.creating = true;
// t
window.XE.MVVM.watch(t, 'creating', (n: any) => {
console.log('creating', n);
// console.log('n', n);
if (n == false) {
//
let positions: any = [];
@ -1108,6 +1110,7 @@
} else {
positions = t.positions;
}
//
t.destroy();
/**
@ -1118,14 +1121,21 @@
nextTick(() => {
addPolyline(positions);
});
} else {
}
});
window.XE.MVVM.watch(t, 'positions', (n: any) => {
console.log('positions', n);
});
});
}
/**
* @params 需要调用 addArea 方法进行绘图获取坐标点position
*/
function addPolyline(positions: any = null) {
// console.log('positions', positions);
//
// cancel();
//
@ -1136,7 +1146,7 @@
};
//
currentModel.xbsjFromJSON(objConfig);
console.log('currentModel', currentModel);
// console.log('currentModel', currentModel);
// ui
const earthUI = window.$uia;
// ui
@ -1158,6 +1168,8 @@
const cancelBtn = el.children[3].children[0];
//
const okBtn = el.children[3].children[1];
//
const xBtn = el.children[1].children[1];
//
okBtn.onclick = function () {
$mitt.emit('windowCancel');
@ -1303,12 +1315,15 @@
});
};
//
cancelBtn.onclick = function () {
cancelBtn.onclick = xBtn.onclick = function () {
$mitt.off('windowCancel');
// dom
el.remove();
//
currentModel.destroy();
// mitt
$mitt.emit('drawShapeShow', { show: false });
$mitt.off('addAreaFinished');
};
});
return currentModel;

9
src/components/earthMap/toolbar/AddRadarCom.vue

@ -2,7 +2,7 @@
* @Author: Fuyuu 1805498209@qq.com
* @Date: 2024-01-10 15:19:50
* @LastEditors: Fuyuu 1805498209@qq.com
* @LastEditTime: 2024-01-11 15:50:45
* @LastEditTime: 2024-01-11 18:26:24
* @FilePath: \dt-admin-pc-v2\src\components\earthMap\toolbar\AddWaveCom.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
@ -180,7 +180,7 @@
//
let selectDeviceNum = ref(null);
//
let uploadFile:any = ref(null);
let uploadFile: any = ref(null);
//
let previewImgUrl = ref('');
//
@ -317,8 +317,8 @@
//
show.value = false;
//
modelState('creating');
// modelState('creating');
// modelState('creating');
return pin;
}
//
@ -535,6 +535,7 @@
currentModel.value = addPin();
});
});
console.log('1111', currentModel.value);
});
return {

13
src/components/earthMap/toolbar/AddWaveCom.vue

@ -2,7 +2,7 @@
* @Author: Fuyuu 1805498209@qq.com
* @Date: 2024-01-10 15:19:50
* @LastEditors: Fuyuu 1805498209@qq.com
* @LastEditTime: 2024-01-11 15:49:37
* @LastEditTime: 2024-01-11 18:24:28
* @FilePath: \dt-admin-pc-v2\src\components\earthMap\toolbar\AddWaveCom.vue
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
@ -267,13 +267,20 @@
pin.pinBuilder.extTextPixelOffset = [30, -20];
pin.pinBuilder.fillColor = [1, 1, 1, 0.9];
pin.pinBuilder.outlineColor = [0, 0, 0, 0.9];
//
pin.onmouseover = () => {
window.$earth.czm.viewer._container.style.cursor = 'pointer';
};
pin.onmouseout = () => {
window.$earth.czm.viewer._container.style.cursor = 'default';
};
//
bindPinProps(pin);
//
show.value = false;
//
modelState('creating');
modelState('creating');
// modelState('creating');
// modelState('creating');
return pin;
}
//

1
src/utils/earthMap/earthObj.ts

@ -377,6 +377,7 @@ export const addShipTrack = (positions: number[][]) => {
const shipTrack = new window.XE.Obj.Polyline(window.$earth);
const objConfig = {
width: 3.0,
name: '轨迹线',
positions,
material: {
type: 'XbsjODLineMaterial',

Loading…
Cancel
Save