Browse Source

添加地图元素显隐组件

master
Fuyuu 8 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 * @Author: Fuyuu 1805498209@qq.com
* @Date: 2024-01-05 14:18:33 * @Date: 2024-01-05 14:18:33
* @LastEditors: Fuyuu 1805498209@qq.com * @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 * @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 * @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 { defineComponent, getCurrentInstance, ref, watch } from 'vue';
import Window from '@/components/earthMap/components/Window.vue'; import Window from '@/components/earthMap/components/Window.vue';
import { useEarthMapStore } from '/@/store/modules/earthMap'; import { useEarthMapStore } from '/@/store/modules/earthMap';
import $mitt from '@/utils/earthMap/mitt';
// store // store
const store = useEarthMapStore(); const store = useEarthMapStore();
export default defineComponent({ export default defineComponent({
@ -138,9 +139,10 @@
// guid // guid
watch( watch(
() => proxy.ship_guid, () => proxy.ship_guid,
(newVal, oldVal) => { (newVal, _oldVal) => {
console.log(newVal); console.log(newVal);
},{immediate : true} },
{ immediate: true }
); );
// //
@ -152,7 +154,21 @@
checked.value = e; checked.value = e;
// 使show // 使show
trackData.show = e; trackData.show = e;
// 线
$mitt.emit('trackShowChange', e);
}
$mitt.on('trackAllChange', (e: boolean) => {
// 线
checked.value = e;
});
$mitt.on('shipAllChange', (e: boolean) => {
//
if (!e) {
cancel()
} }
})
return { return {
checked, checked,

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

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

@ -2,7 +2,7 @@
* @Author: Fuyuu 1805498209@qq.com * @Author: Fuyuu 1805498209@qq.com
* @Date: 2024-01-10 15:19:50 * @Date: 2024-01-10 15:19:50
* @LastEditors: Fuyuu 1805498209@qq.com * @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 * @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 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
--> -->
@ -180,7 +180,7 @@
// //
let selectDeviceNum = ref(null); let selectDeviceNum = ref(null);
// //
let uploadFile:any = ref(null); let uploadFile: any = ref(null);
// //
let previewImgUrl = ref(''); let previewImgUrl = ref('');
// //
@ -317,8 +317,8 @@
// //
show.value = false; show.value = false;
// //
modelState('creating'); // modelState('creating');
// modelState('creating');
return pin; return pin;
} }
// //
@ -535,6 +535,7 @@
currentModel.value = addPin(); currentModel.value = addPin();
}); });
}); });
console.log('1111', currentModel.value);
}); });
return { return {

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

@ -2,7 +2,7 @@
* @Author: Fuyuu 1805498209@qq.com * @Author: Fuyuu 1805498209@qq.com
* @Date: 2024-01-10 15:19:50 * @Date: 2024-01-10 15:19:50
* @LastEditors: Fuyuu 1805498209@qq.com * @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 * @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 * @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.extTextPixelOffset = [30, -20];
pin.pinBuilder.fillColor = [1, 1, 1, 0.9]; pin.pinBuilder.fillColor = [1, 1, 1, 0.9];
pin.pinBuilder.outlineColor = [0, 0, 0, 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); bindPinProps(pin);
// //
show.value = false; show.value = false;
// //
modelState('creating'); // modelState('creating');
modelState('creating'); // modelState('creating');
return pin; 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 shipTrack = new window.XE.Obj.Polyline(window.$earth);
const objConfig = { const objConfig = {
width: 3.0, width: 3.0,
name: '轨迹线',
positions, positions,
material: { material: {
type: 'XbsjODLineMaterial', type: 'XbsjODLineMaterial',

Loading…
Cancel
Save