|
@@ -39,19 +39,21 @@
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup name="OnlinePlotting">
|
|
|
-import {computed, inject, onMounted, reactive, ref, watch} from "vue";
|
|
|
+import {computed, inject, reactive, ref, watch} from "vue";
|
|
|
import {nanoid} from "nanoid";
|
|
|
import {deepClone} from "@/utils";
|
|
|
import {useHistory} from "@/hooks/useHistory";
|
|
|
import { ElColorPicker } from 'element-plus';
|
|
|
import TextEdit from "./TextEdit.vue";
|
|
|
|
|
|
-const emits = defineEmits(['update:modelValue']);
|
|
|
+const emits = defineEmits(['update:modelValue', 'update:onlinePlottingId', 'handleSendData']);
|
|
|
+const getMapUtils = inject('getMapUtils');
|
|
|
const getDrawTool = inject('getDrawTool');
|
|
|
const getMap = inject('getMap');
|
|
|
const { currentState, commit, undo, history, future } = useHistory();
|
|
|
const props = defineProps({
|
|
|
- modelValue: Boolean
|
|
|
+ modelValue: Boolean,
|
|
|
+ onlinePlottingId: String
|
|
|
});
|
|
|
let drawing = ref(false);
|
|
|
const mouseToolState = ref({
|
|
@@ -67,6 +69,7 @@ const show = computed({
|
|
|
emits('update:modelValue', value);
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
const getImageUrl = (name) => {
|
|
|
return new URL(`../../../assets/images/map/onlinePlotting/icon/${name}.png`, import.meta.url).href;
|
|
|
};
|
|
@@ -144,98 +147,97 @@ const menu = ref([
|
|
|
name: '火点',
|
|
|
value: 'firePoint',
|
|
|
children: [
|
|
|
- { name: '起火点', value: 'marker', image: getImageUrl('firePoint'), icon: getImageUrl('firePoint'), size: [55, 29] },
|
|
|
- { name: '烟点', value: 'marker', image: getImageUrl('smokePoint'), icon: getImageUrl('smokePoint'), size: [55, 29] },
|
|
|
- { name: '已灭火点', value: 'marker', image: getImageUrl('extinguishedPoint'), icon: getImageUrl('extinguishedPoint'), size: [55, 29] }
|
|
|
+ { name: '起火点', value: 'marker', image: getImageUrl('firePoint'), icon: 'firePoint', size: [55, 29] },
|
|
|
+ { name: '烟点', value: 'marker', image: getImageUrl('smokePoint'), icon: 'smokePoint', size: [55, 29] },
|
|
|
+ { name: '已灭火点', value: 'marker', image: getImageUrl('extinguishedPoint'), icon: 'extinguishedPoint', size: [55, 29] }
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
name: '火线',
|
|
|
value: 'firewire',
|
|
|
children: [
|
|
|
- { name: '火线', value: 'marker', image: getImageUrl('firewire'), icon: getImageUrl('firewire'), size: [55, 29] },
|
|
|
- { name: '受控火线', value: 'marker', image: getImageUrl('controlledfireline'), icon: getImageUrl('controlledfireline'), size: [55, 29] },
|
|
|
- { name: '已灭火线', value: 'marker', image: getImageUrl('extinguishedline'), icon: getImageUrl('extinguishedline'), size: [55, 29] },
|
|
|
- { name: '强火线', value: 'marker', image: getImageUrl('StrongFrontline'), icon: getImageUrl('StrongFrontline'), size: [55, 29] },
|
|
|
- { name: '中火线', value: 'marker', image: getImageUrl('ZhongxianLine'), icon: getImageUrl('ZhongxianLine'), size: [55, 29] },
|
|
|
- { name: '弱火线', value: 'marker', image: getImageUrl('WeakFrontline'), icon: getImageUrl('WeakFrontline'), size: [55, 29] }
|
|
|
+ { name: '火线', value: 'marker', image: getImageUrl('firewire'), icon: 'firewire', size: [55, 29] },
|
|
|
+ { name: '受控火线', value: 'marker', image: getImageUrl('controlledfireline'), icon: 'controlledfireline', size: [55, 29] },
|
|
|
+ { name: '已灭火线', value: 'marker', image: getImageUrl('extinguishedline'), icon: 'extinguishedline', size: [55, 29] },
|
|
|
+ { name: '强火线', value: 'marker', image: getImageUrl('StrongFrontline'), icon: 'StrongFrontline', size: [55, 29] },
|
|
|
+ { name: '中火线', value: 'marker', image: getImageUrl('ZhongxianLine'), icon: 'ZhongxianLine', size: [55, 29] },
|
|
|
+ { name: '弱火线', value: 'marker', image: getImageUrl('WeakFrontline'), icon: 'WeakFrontline', size: [55, 29] }
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
name: '火场',
|
|
|
value: 'fireGround',
|
|
|
children: [
|
|
|
- { name: '火场', value: 'marker', image: getImageUrl('fireground'), icon: getImageUrl('fireground'), size: [55, 29] },
|
|
|
- { name: '受控火场', value: 'marker', image: getImageUrl('controlledfireground'), icon: getImageUrl('controlledfireground'), size: [55, 29] },
|
|
|
- { name: '已灭火场', value: 'marker', image: getImageUrl('extinguishedfireground'), icon: getImageUrl('extinguishedfireground'), size: [55, 29] }
|
|
|
+ { name: '火场', value: 'marker', image: getImageUrl('fireground'), icon: 'fireground', size: [55, 29] },
|
|
|
+ { name: '受控火场', value: 'marker', image: getImageUrl('controlledfireground'), icon: 'controlledfireground', size: [55, 29] },
|
|
|
+ { name: '已灭火场', value: 'marker', image: getImageUrl('extinguishedfireground'), icon: 'extinguishedfireground', size: [55, 29] }
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
name: '箭头',
|
|
|
value: 'arrow',
|
|
|
children: [
|
|
|
- { name: '曲箭头', value: 'marker', image: getImageUrl('curvedarrow'), icon: getImageUrl('curvedarrow'), size: [55, 29] },
|
|
|
- { name: '直箭头', value: 'marker', image: getImageUrl('straightarrow1'), icon: getImageUrl('straightarrow1'), size: [55, 29] },
|
|
|
- { name: '细箭头', value: 'marker', image: getImageUrl('thinarrow'), icon: getImageUrl('thinarrow'), size: [55, 29] }
|
|
|
+ { name: '曲箭头', value: 'marker', image: getImageUrl('curvedarrow'), icon: 'curvedarrow', size: [55, 29] },
|
|
|
+ { name: '直箭头', value: 'marker', image: getImageUrl('straightarrow1'), icon: 'straightarrow1', size: [55, 29] },
|
|
|
+ { name: '细箭头', value: 'marker', image: getImageUrl('thinarrow'), icon: 'thinarrow', size: [55, 29] }
|
|
|
]
|
|
|
},
|
|
|
// {
|
|
|
// name: '导航',
|
|
|
// value: 'navigation',
|
|
|
// children: [
|
|
|
- // { name: '导航', value: 'marker', image: getImageUrl('navigation'), icon: getImageUrl('navigation'), size: [55, 29] }
|
|
|
+ // { name: '导航', value: 'marker', image: getImageUrl('navigation'), icon: 'navigation', size: [55, 29] }
|
|
|
// ]
|
|
|
// },
|
|
|
{
|
|
|
name: '扑救队伍',
|
|
|
value: 'firefightingTeam',
|
|
|
children: [
|
|
|
- { name: '指挥中心', value: 'marker', image: getImageUrl('commandcentre'), icon: getImageUrl('commandcentre'), size: [55, 29] },
|
|
|
- { name: '分指中心', value: 'marker', image: getImageUrl('dividingcenter'), icon: getImageUrl('dividingcenter'), size: [55, 29] },
|
|
|
- { name: '集结地', value: 'marker', image: getImageUrl('rendezvous'), icon: getImageUrl('rendezvous'), size: [55, 29] },
|
|
|
- { name: '军队', value: 'marker', image: getImageUrl('army'), icon: getImageUrl('army'), size: [55, 29] },
|
|
|
- { name: '武警', value: 'marker', image: getImageUrl('armedpolice'), icon: getImageUrl('armedpolice'), size: [55, 29] },
|
|
|
- { name: '森林警察', value: 'marker', image: getImageUrl('forestpoliceman'), icon: getImageUrl('forestpoliceman'), size: [55, 29] },
|
|
|
- { name: '扑火队伍', value: 'marker', image: getImageUrl('firefightingteam'), icon: getImageUrl('firefightingteam'), size: [55, 29] },
|
|
|
- // { name: '扑火队伍路线', value: 'marker', image: getImageUrl('Firefightingteamroute'), icon: getImageUrl('Firefightingteamroute'), size: [55, 29] }
|
|
|
+ { name: '指挥中心', value: 'marker', image: getImageUrl('commandcentre'), icon: 'commandcentre', size: [55, 29] },
|
|
|
+ { name: '分指中心', value: 'marker', image: getImageUrl('dividingcenter'), icon: 'dividingcenter', size: [55, 29] },
|
|
|
+ { name: '集结地', value: 'marker', image: getImageUrl('rendezvous'), icon: 'rendezvous', size: [55, 29] },
|
|
|
+ { name: '军队', value: 'marker', image: getImageUrl('army'), icon: 'army', size: [55, 29] },
|
|
|
+ { name: '武警', value: 'marker', image: getImageUrl('armedpolice'), icon: 'armedpolice', size: [55, 29] },
|
|
|
+ { name: '森林警察', value: 'marker', image: getImageUrl('forestpoliceman'), icon: 'forestpoliceman', size: [55, 29] },
|
|
|
+ { name: '扑火队伍', value: 'marker', image: getImageUrl('firefightingteam'), icon: 'firefightingteam', size: [55, 29] },
|
|
|
+ // { name: '扑火队伍路线', value: 'marker', image: getImageUrl('Firefightingteamroute'), icon: 'Firefightingteamroute', size: [55, 29] }
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
name: '飞机车辆',
|
|
|
value: 'aircraftVehicles',
|
|
|
children: [
|
|
|
- { name: '固定翼', value: 'marker', image: getImageUrl('fixedwing'), icon: getImageUrl('fixedwing'), size: [55, 29] },
|
|
|
- { name: '直升机', value: 'marker', image: getImageUrl('helicopter'), icon: getImageUrl('helicopter'), size: [55, 29] },
|
|
|
- { name: '无人机', value: 'marker', image: getImageUrl('UAV'), icon: getImageUrl('UAV'), size: [55, 29] },
|
|
|
- { name: '指挥车', value: 'marker', image: getImageUrl('commandvehicle'), icon: getImageUrl('commandvehicle'), size: [55, 29] },
|
|
|
- { name: '飞机航线设置', value: 'marker', image: getImageUrl('aircraftroutesetting'), icon: getImageUrl('aircraftroutesetting'), size: [55, 29] },
|
|
|
- { name: '直升机航线设置', value: 'marker', image: getImageUrl('helicopterroutesetting'), icon: getImageUrl('helicopterroutesetting'), size: [55, 29] }
|
|
|
+ { name: '固定翼', value: 'marker', image: getImageUrl('fixedwing'), icon: 'fixedwing', size: [55, 29] },
|
|
|
+ { name: '直升机', value: 'marker', image: getImageUrl('helicopter'), icon: 'helicopter', size: [55, 29] },
|
|
|
+ { name: '无人机', value: 'marker', image: getImageUrl('UAV'), icon: 'UAV', size: [55, 29] },
|
|
|
+ { name: '指挥车', value: 'marker', image: getImageUrl('commandvehicle'), icon: 'commandvehicle', size: [55, 29] },
|
|
|
+ { name: '飞机航线设置', value: 'marker', image: getImageUrl('aircraftroutesetting'), icon: 'aircraftroutesetting', size: [55, 29] },
|
|
|
+ { name: '直升机航线设置', value: 'marker', image: getImageUrl('helicopterroutesetting'), icon: 'helicopterroutesetting', size: [55, 29] }
|
|
|
]
|
|
|
},
|
|
|
{
|
|
|
name: '基础设置',
|
|
|
value: 'basicSetting',
|
|
|
children: [
|
|
|
- { name: '航站', value: 'marker', image: getImageUrl('terminal'), icon: getImageUrl('terminal'), size: [55, 29] },
|
|
|
- { name: '起降点', value: 'marker', image: getImageUrl('takeoffandlandingpoint'), icon: getImageUrl('takeoffandlandingpoint'), size: [55, 29] },
|
|
|
- { name: '取水点', value: 'marker', image: getImageUrl('waterpoint'), icon: getImageUrl('waterpoint'), size: [55, 29] },
|
|
|
- { name: '瞭望塔', value: 'marker', image: getImageUrl('watchtower'), icon: getImageUrl('watchtower'), size: [55, 29] },
|
|
|
- { name: '物资库', value: 'marker', image: getImageUrl('materialwarehouse'), icon: getImageUrl('materialwarehouse'), size: [55, 29] },
|
|
|
-
|
|
|
+ { name: '航站', value: 'marker', image: getImageUrl('terminal'), icon: 'terminal', size: [55, 29] },
|
|
|
+ { name: '起降点', value: 'marker', image: getImageUrl('takeoffandlandingpoint'), icon: 'takeoffandlandingpoint', size: [55, 29] },
|
|
|
+ { name: '取水点', value: 'marker', image: getImageUrl('waterpoint'), icon: 'waterpoint', size: [55, 29] },
|
|
|
+ { name: '瞭望塔', value: 'marker', image: getImageUrl('watchtower'), icon: 'watchtower', size: [55, 29] },
|
|
|
+ { name: '物资库', value: 'marker', image: getImageUrl('materialwarehouse'), icon: 'materialwarehouse', size: [55, 29] },
|
|
|
]
|
|
|
},
|
|
|
// {
|
|
|
// name: '其他',
|
|
|
// value: 'other',
|
|
|
// children: [
|
|
|
- // { name: '危险区域', value: 'marker', image: getImageUrl('dangerousarea'), icon: getImageUrl('dangerousarea'), size: [55, 29] },
|
|
|
- // { name: '隔离带开采', value: 'marker', image: getImageUrl('Isolationzonemining'), icon: getImageUrl('Isolationzonemining'), size: [55, 29] },
|
|
|
- // { name: '应急庇护场所', value: 'marker', image: getImageUrl('emergencyshelter'), icon: getImageUrl('emergencyshelter'), size: [55, 29] },
|
|
|
- // { name: '风力风向', value: 'marker', image: getImageUrl('windspeedanddirection'), icon: getImageUrl('windspeedanddirection'), size: [55, 29] },
|
|
|
- // { name: '测距', value: 'marker', image: getImageUrl('ranging'), icon: getImageUrl('ranging'), size: [55, 29] },
|
|
|
- // { name: '大风', value: 'marker', image: getImageUrl('strongwind'), icon: getImageUrl('strongwind'), size: [55, 29] },
|
|
|
- // { name: '人工降雨', value: 'marker', image: getImageUrl('artificialrainfall'), icon: getImageUrl('artificialrainfall'), size: [55, 29] },
|
|
|
- // { name: '台风', value: 'marker', image: getImageUrl('typhoon'), icon: getImageUrl('typhoon'), size: [55, 29] }
|
|
|
+ // { name: '危险区域', value: 'marker', image: getImageUrl('dangerousarea'), icon: 'dangerousarea', size: [55, 29] },
|
|
|
+ // { name: '隔离带开采', value: 'marker', image: getImageUrl('Isolationzonemining'), icon: 'Isolationzonemining', size: [55, 29] },
|
|
|
+ // { name: '应急庇护场所', value: 'marker', image: getImageUrl('emergencyshelter'), icon: 'emergencyshelter', size: [55, 29] },
|
|
|
+ // { name: '风力风向', value: 'marker', image: getImageUrl('windspeedanddirection'), icon: 'windspeedanddirection', size: [55, 29] },
|
|
|
+ // { name: '测距', value: 'marker', image: getImageUrl('ranging'), icon: 'ranging', size: [55, 29] },
|
|
|
+ // { name: '大风', value: 'marker', image: getImageUrl('strongwind'), icon: 'strongwind', size: [55, 29] },
|
|
|
+ // { name: '人工降雨', value: 'marker', image: getImageUrl('artificialrainfall'), icon: 'artificialrainfall', size: [55, 29] },
|
|
|
+ // { name: '台风', value: 'marker', image: getImageUrl('typhoon'), icon: 'typhoon', size: [55, 29] }
|
|
|
// ]
|
|
|
// }
|
|
|
]
|
|
@@ -250,20 +252,18 @@ const menu = ref([
|
|
|
// 点击三级菜单
|
|
|
const clickTab = (item, index) => {
|
|
|
const type = item.value;
|
|
|
- // getMap().setStatus({
|
|
|
- // dragEnable: false,
|
|
|
- // doubleClickZoom: false
|
|
|
- // })
|
|
|
if (mouseToolState.value.graphicsType !== type || (mouseToolState.value.graphicsType === 'marker' && mouseToolState.value.title !== item.name)) {
|
|
|
if (type === 'text') {
|
|
|
mouseToolState.value.graphicsType = type;
|
|
|
+ mouseToolState.value.title = item.name;
|
|
|
handleTextEdit();
|
|
|
} else if (type === 'marker') {
|
|
|
const data = {
|
|
|
graphicsType: type,
|
|
|
lineWidth: mouseToolState.value.lineWidth,
|
|
|
color: mouseToolState.value.color,
|
|
|
- icon: item.icon,
|
|
|
+ icon: getImageUrl(item.icon),
|
|
|
+ iconName: item.icon,
|
|
|
size: item.size,
|
|
|
title: item.name
|
|
|
};
|
|
@@ -273,6 +273,7 @@ const clickTab = (item, index) => {
|
|
|
showTextEdit.value = false;
|
|
|
drawing.value = true;
|
|
|
mouseToolState.value.graphicsType = type;
|
|
|
+ mouseToolState.value.title = item.name;
|
|
|
}
|
|
|
emits('update:modelValue', false);
|
|
|
const drawTool = getDrawTool();
|
|
@@ -304,8 +305,10 @@ const handleTextEdit = () => {
|
|
|
const addText = (textEditState) => {
|
|
|
const data = {
|
|
|
graphicsType: 'text',
|
|
|
+ type: 'text',
|
|
|
lineWidth: mouseToolState.value.lineWidth,
|
|
|
color: mouseToolState.value.color,
|
|
|
+ title: '文本',
|
|
|
text: textEditState.text,
|
|
|
fontColor: textEditState.fontColor,
|
|
|
fontSize: textEditState.fontSize,
|
|
@@ -325,7 +328,23 @@ const addText = (textEditState) => {
|
|
|
// 监听地图点击事件
|
|
|
map.off('click', handleClickMap);
|
|
|
close();
|
|
|
+ emits('handleSendData', JSON.stringify({
|
|
|
+ operation: 'add', // 必填
|
|
|
+ name: data.title, // 必填
|
|
|
+ content: JSON.stringify(data), // 必填
|
|
|
+ visible: false
|
|
|
+ }));
|
|
|
};
|
|
|
+watch(() => props.onlinePlottingId, () => {
|
|
|
+ if (props.onlinePlottingId !== null) {
|
|
|
+ const drawTool = getDrawTool();
|
|
|
+ const map = drawTool.getMap();
|
|
|
+ if (!!map) {
|
|
|
+ map.off('click', handleClickMap);
|
|
|
+ }
|
|
|
+ close();
|
|
|
+ }
|
|
|
+});
|
|
|
const close = () => {
|
|
|
const drawTool = getDrawTool();
|
|
|
drawTool.closeDraw();
|
|
@@ -340,10 +359,6 @@ const initDrawMethod = (options) => {
|
|
|
|
|
|
const onDraw = (event) => {
|
|
|
mouseTool.off('draw', onDraw);
|
|
|
- // getMap().setStatus({
|
|
|
- // dragEnable: true,
|
|
|
- // doubleClickZoom: true
|
|
|
- // })
|
|
|
close();
|
|
|
const obj = event.obj;
|
|
|
const id = nanoid();
|
|
@@ -354,7 +369,17 @@ const initDrawMethod = (options) => {
|
|
|
data.id = id;
|
|
|
if (options.type == 'marker') {
|
|
|
const position = obj.getPosition();
|
|
|
- data.path = [position.lng, position.lat];
|
|
|
+ data.lnglat = [position.lng, position.lat];
|
|
|
+ data.latitude = position.lat;
|
|
|
+ data.longitude = position.lng;
|
|
|
+ data.icon = data.iconName;
|
|
|
+ data.image = data.iconName;
|
|
|
+ data.imageHover = data.iconName;
|
|
|
+ data.visible = true;
|
|
|
+ obj.setLabel({
|
|
|
+ content: '<div>' + data.title + '</div>',
|
|
|
+ direction: 'top'
|
|
|
+ });
|
|
|
} else {
|
|
|
const path = obj.getPath();
|
|
|
// 将AMap.LngLat对象数组转换为经纬度数组
|
|
@@ -394,6 +419,12 @@ const initDrawMethod = (options) => {
|
|
|
}
|
|
|
// 右击进入编辑
|
|
|
obj.on('rightclick', handleRightClick);
|
|
|
+ emits('handleSendData', JSON.stringify({
|
|
|
+ operation: 'add', // 必填
|
|
|
+ name: data.title, // 必填
|
|
|
+ content: JSON.stringify(data), // 必填
|
|
|
+ visible: false
|
|
|
+ }))
|
|
|
};
|
|
|
mouseTool.on('draw', onDraw);
|
|
|
};
|
|
@@ -446,6 +477,22 @@ const removeOverlayByIndex = (index: number) => {
|
|
|
overlays.splice(index, 1);
|
|
|
overlaysData.splice(index, 1);
|
|
|
};
|
|
|
+const getWebSocketData = (data) => {
|
|
|
+ if(data && data.length > 0) {
|
|
|
+ const data2 = []
|
|
|
+ data.forEach((item) => {
|
|
|
+ if (!!item.content) {
|
|
|
+ const parseContent = JSON.parse(item.content);
|
|
|
+ if (parseContent.type === 'marker' && !!parseContent.icon) {
|
|
|
+ parseContent.icon = getImageUrl(parseContent.icon);
|
|
|
+ }
|
|
|
+ data2.push(parseContent);
|
|
|
+ }
|
|
|
+ })
|
|
|
+ getMapUtils().drawData(data2);
|
|
|
+ }
|
|
|
+}
|
|
|
+defineExpose({ getWebSocketData })
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|