|
@@ -1,27 +1,40 @@
|
|
<template>
|
|
<template>
|
|
<div ref="containerRef" class="map-container">
|
|
<div ref="containerRef" class="map-container">
|
|
- <div ref="mapRef" id="YztMap" class="map-container" :style="{ width: width, height: height }"></div>
|
|
|
|
|
|
+ <div
|
|
|
|
+ ref="mapRef"
|
|
|
|
+ id="YztMap"
|
|
|
|
+ class="map-container"
|
|
|
|
+ :style="{
|
|
|
|
+ width: width,
|
|
|
|
+ height: height
|
|
|
|
+ }"
|
|
|
|
+ ></div>
|
|
<rightTool :mapState="mapState" type="YztMap" :showMask="showMask" @changeShowMask="changeShowMask" />
|
|
<rightTool :mapState="mapState" type="YztMap" :showMask="showMask" @changeShowMask="changeShowMask" />
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
import 'ol/ol.css';
|
|
import 'ol/ol.css';
|
|
-import ScaleLine from 'ol/control/ScaleLine';
|
|
|
|
|
|
+import rightTool from '../rightTool.vue';
|
|
import mmJson from '@/assets/json/mm2.json';
|
|
import mmJson from '@/assets/json/mm2.json';
|
|
import { olMap } from '@/utils/olMap/olMap';
|
|
import { olMap } from '@/utils/olMap/olMap';
|
|
import { PointType } from '@/api/globalMap/type';
|
|
import { PointType } from '@/api/globalMap/type';
|
|
-import QuickZoom from '@/components/Map/quickZoom.vue';
|
|
|
|
|
|
+import { ScaleLine } from 'ol/control';
|
|
|
|
+import { getPointInfoList } from '@/api/globalMap';
|
|
|
|
+import { getDictLabel } from '@/utils/dict';
|
|
|
|
+import { methodList, titleList } from '../data';
|
|
|
|
+import { pointDetailTemplate } from '@/views/globalMap/data/mapData';
|
|
|
|
|
|
interface Props {
|
|
interface Props {
|
|
activeMap: string;
|
|
activeMap: string;
|
|
- // 获取需要查询点的类型
|
|
|
|
- pointType?: PointType[];
|
|
|
|
|
|
+ pointType: PointType[];
|
|
showMask: boolean;
|
|
showMask: boolean;
|
|
}
|
|
}
|
|
const containerScale = inject('containerScale');
|
|
const containerScale = inject('containerScale');
|
|
const props = withDefaults(defineProps<Props>(), {});
|
|
const props = withDefaults(defineProps<Props>(), {});
|
|
-const emits = defineEmits(['update:drawing', 'update:showMask', 'selectGraphics']);
|
|
|
|
|
|
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
|
+const { point_type } = toRefs<any>(proxy?.useDict('point_type'));
|
|
|
|
+const emits = defineEmits(['update:drawing', 'update:showMask', 'selectGraphics', 'handleShowWarehouse', 'handleShowVideo', 'handleShowPeople']);
|
|
|
|
|
|
const mapRef = ref(null);
|
|
const mapRef = ref(null);
|
|
const mapState = reactive({
|
|
const mapState = reactive({
|
|
@@ -100,8 +113,8 @@ const init = () => {
|
|
}
|
|
}
|
|
},
|
|
},
|
|
// 加载完成事件
|
|
// 加载完成事件
|
|
- onLoadCompleted: (yMap) => {
|
|
|
|
- map = yMap;
|
|
|
|
|
|
+ onLoadCompleted: (YztMap) => {
|
|
|
|
+ map = YztMap;
|
|
// initMouseTool(mapUtils);
|
|
// initMouseTool(mapUtils);
|
|
scale = new ScaleLine();
|
|
scale = new ScaleLine();
|
|
map.addControl(scale);
|
|
map.addControl(scale);
|
|
@@ -112,13 +125,195 @@ const init = () => {
|
|
mapUtils.createVecByJson2(mmJson, { strokeWeight: 2 });
|
|
mapUtils.createVecByJson2(mmJson, { strokeWeight: 2 });
|
|
}
|
|
}
|
|
handleResize();
|
|
handleResize();
|
|
|
|
+ },
|
|
|
|
+ onMarkerClick: (data) => {
|
|
|
|
+ // 多点位
|
|
|
|
+ if (data.type === '1') {
|
|
|
|
+ let path = [];
|
|
|
|
+ props.pointType.forEach((item) => {
|
|
|
|
+ path.push(item.component);
|
|
|
|
+ });
|
|
|
|
+ getPointInfoList({
|
|
|
|
+ option: path.toString(),
|
|
|
|
+ longitude: data.longitude.toString(),
|
|
|
|
+ latitude: data.latitude.toString()
|
|
|
|
+ }).then((res) => {
|
|
|
|
+ const data2 = res.data.list;
|
|
|
|
+ let content = document.createElement('div');
|
|
|
|
+ // content.style.cssText = 'transform: scale(' + containerScale().scaleX + ');';
|
|
|
|
+ content.className = 'point-info';
|
|
|
|
+ let content2 = '';
|
|
|
|
+ content2 += '<div class="title-box"><div class="gradient-text">多点位信息</div></div>';
|
|
|
|
+ content2 += '<div class="icon1"></div>';
|
|
|
|
+ content2 += '<div class="icon2"></div>';
|
|
|
|
+ content2 += '<div class="icon3"></div>';
|
|
|
|
+ content2 += '<div class="icon4"></div>';
|
|
|
|
+ content.innerHTML = content2;
|
|
|
|
+ let tableBox = document.createElement('div');
|
|
|
|
+ tableBox.className = 'table-box';
|
|
|
|
+ let table = document.createElement('div');
|
|
|
|
+ table.className = 'table';
|
|
|
|
+ table.innerHTML = '<div class="point-item"><div class="td3">主题</div><div class="td3">名称</div></div>';
|
|
|
|
+ data2.forEach((item) => {
|
|
|
|
+ item.longitude = data.longitude;
|
|
|
|
+ item.latitude = data.latitude;
|
|
|
|
+ const div = document.createElement('div');
|
|
|
|
+ div.className = 'point-item point-item-hover';
|
|
|
|
+ div.innerHTML =
|
|
|
|
+ '<div class="td4">' + getDictLabel(point_type.value, item.dataType.toString()) + '</div><div class="td4">' + item.name + '</div>';
|
|
|
|
+ div.addEventListener('click', () => {
|
|
|
|
+ handlePointDetails(item);
|
|
|
|
+ });
|
|
|
|
+ table.appendChild(div);
|
|
|
|
+ });
|
|
|
|
+ tableBox.appendChild(table);
|
|
|
|
+ content.appendChild(tableBox);
|
|
|
|
+ let closeBtn = document.createElement('div');
|
|
|
|
+ closeBtn.className = 'close';
|
|
|
|
+ closeBtn.onclick = () => mapUtils.hideInfo(true);
|
|
|
|
+ content.appendChild(closeBtn);
|
|
|
|
+ mapUtils.showInfo(content, [data.longitude, data.latitude], true);
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ handlePointDetails(data);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
+const handlePointDetails = (data) => {
|
|
|
|
+ let method = methodList[data.dataType];
|
|
|
|
+ let title = !!titleList[data.dataType] ? titleList[data.dataType] : '信息';
|
|
|
|
+ if (!method) return;
|
|
|
|
+ method(data.id).then((res) => {
|
|
|
|
+ if (!!pointDetailTemplate[data.dataType]) {
|
|
|
|
+ let div = document.createElement('div');
|
|
|
|
+ // div.style.cssText = 'transform: scale(' + containerScale().scaleX + ');';
|
|
|
|
+ div.className = 'point-info';
|
|
|
|
+ let titleDom = document.createElement('div');
|
|
|
|
+ titleDom.className = 'title-box';
|
|
|
|
+ titleDom.innerHTML = '<div class="gradient-text">' + title + '</div></div>';
|
|
|
|
+ div.appendChild(titleDom);
|
|
|
|
+ if (data.dataType === 2) {
|
|
|
|
+ let btnBox = document.createElement('div');
|
|
|
|
+ let btn = document.createElement('div');
|
|
|
|
+ btnBox.className = 'flex';
|
|
|
|
+ btn.className = 'btn';
|
|
|
|
+ btn.innerHTML = '<div class="video-icon"></div><div>物资详情</div>';
|
|
|
|
+ btn.onclick = () => {
|
|
|
|
+ emits('handleShowWarehouse', data);
|
|
|
|
+ };
|
|
|
|
+ btnBox.appendChild(btn);
|
|
|
|
+ div.appendChild(btnBox);
|
|
|
|
+ } else if (data.dataType === 4) {
|
|
|
|
+ let btnBox = document.createElement('div');
|
|
|
|
+ let btn = document.createElement('div');
|
|
|
|
+ btnBox.className = 'flex';
|
|
|
|
+ btn.className = 'btn';
|
|
|
|
+ btn.innerHTML = '<div class="video-icon"></div><div>附近视频</div>';
|
|
|
|
+ btn.onclick = () => {
|
|
|
|
+ emits('handleShowVideo', data);
|
|
|
|
+ };
|
|
|
|
+ btnBox.appendChild(btn);
|
|
|
|
+ div.appendChild(btnBox);
|
|
|
|
+ } else if (data.dataType === 41) {
|
|
|
|
+ let btnBox = document.createElement('div');
|
|
|
|
+ let btn = document.createElement('div');
|
|
|
|
+ btnBox.className = 'flex';
|
|
|
|
+ btn.className = 'btn';
|
|
|
|
+ btn.innerHTML = '<div class="video-icon"></div><div>人员列表</div>';
|
|
|
|
+ btn.onclick = () => {
|
|
|
|
+ emits('handleShowPeople', data);
|
|
|
|
+ };
|
|
|
|
+ btnBox.appendChild(btn);
|
|
|
|
+ div.appendChild(btnBox);
|
|
|
|
+ }
|
|
|
|
+ let icon1 = document.createElement('div');
|
|
|
|
+ icon1.className = 'icon1';
|
|
|
|
+ let icon2 = document.createElement('div');
|
|
|
|
+ icon2.className = 'icon2';
|
|
|
|
+ let icon3 = document.createElement('div');
|
|
|
|
+ icon3.className = 'icon3';
|
|
|
|
+ let icon4 = document.createElement('div');
|
|
|
|
+ icon4.className = 'icon4';
|
|
|
|
+ div.appendChild(icon1);
|
|
|
|
+ div.appendChild(icon2);
|
|
|
|
+ div.appendChild(icon3);
|
|
|
|
+ div.appendChild(icon4);
|
|
|
|
+ let table = document.createElement('div');
|
|
|
|
+ table.className = 'table-box';
|
|
|
|
+ let content = '';
|
|
|
|
+ content += '<div class="table">';
|
|
|
|
+ const newData = filterTd(res.rows[0], data.dataType);
|
|
|
|
+ newData.forEach((item) => {
|
|
|
|
+ if (item.type === 'shortText') {
|
|
|
|
+ content += '<div class="tr">';
|
|
|
|
+ item.data.forEach((item2) => {
|
|
|
|
+ content += '<div class="point-item">';
|
|
|
|
+ content += '<div class="td1">' + item2.label + '</div><div class="td2">' + item2.value + '</div>';
|
|
|
|
+ content += '</div>';
|
|
|
|
+ });
|
|
|
|
+ content += '</div>';
|
|
|
|
+ } else {
|
|
|
|
+ content += '<div class="point-item2">';
|
|
|
|
+ content += '<div class="td1">' + item.data[0].label + '</div><div class="td2">' + item.data[0].value + '</div>';
|
|
|
|
+ content += '</div>';
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ content += '</div>';
|
|
|
|
+ table.innerHTML = content;
|
|
|
|
+ div.appendChild(table);
|
|
|
|
+ let closeBtn = document.createElement('div');
|
|
|
|
+ closeBtn.className = 'close';
|
|
|
|
+ closeBtn.onclick = () => mapUtils.hideInfo(true);
|
|
|
|
+ div.appendChild(closeBtn);
|
|
|
|
+ mapUtils.showInfo(div, [data.longitude, data.latitude], true);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+};
|
|
|
|
+const filterTd = (obj, dataType) => {
|
|
|
|
+ let data = [];
|
|
|
|
+ let tempData = {};
|
|
|
|
+ let i = 0;
|
|
|
|
+ for (let key in obj) {
|
|
|
|
+ let keyLabel = pointDetailTemplate[dataType][key];
|
|
|
|
+ if (!!keyLabel) {
|
|
|
|
+ if (i === 2) {
|
|
|
|
+ i = 0;
|
|
|
|
+ }
|
|
|
|
+ const value = !!obj[key] ? obj[key] : '';
|
|
|
|
+ if (value && value.length > 8) {
|
|
|
|
+ if (i === 0) {
|
|
|
|
+ data.push({ type: 'longText', data: [{ label: keyLabel, value: value }] });
|
|
|
|
+ i = 0;
|
|
|
|
+ } else {
|
|
|
|
+ tempData = { type: 'longText', data: [{ label: keyLabel, value: value }] };
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ if (i === 0) {
|
|
|
|
+ data.push({ type: 'shortText', data: [{ label: keyLabel, value: value }] });
|
|
|
|
+ } else {
|
|
|
|
+ data[data.length - 1].data.push({ label: keyLabel, value: value });
|
|
|
|
+ }
|
|
|
|
+ i++;
|
|
|
|
+ if (!!tempData && JSON.stringify(tempData) !== '{}') {
|
|
|
|
+ data.push(tempData);
|
|
|
|
+ tempData = {};
|
|
|
|
+ i = 0;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!!tempData && JSON.stringify(tempData) !== '{}') {
|
|
|
|
+ data.push(tempData);
|
|
|
|
+ }
|
|
|
|
+ if (data[data.length - 1].data && data[data.length - 1].data.length === 1 && data[data.length - 1].type === 'shortText') {
|
|
|
|
+ data[data.length - 1].data[1] = { label: '', value: '' };
|
|
|
|
+ }
|
|
|
|
+ return data;
|
|
|
|
+};
|
|
const addMarker = (points) => {
|
|
const addMarker = (points) => {
|
|
mapUtils.addMarker(points);
|
|
mapUtils.addMarker(points);
|
|
};
|
|
};
|
|
-
|
|
|
|
const clearMarker = () => {
|
|
const clearMarker = () => {
|
|
mapUtils.clearMarker();
|
|
mapUtils.clearMarker();
|
|
};
|
|
};
|
|
@@ -132,6 +327,15 @@ const handleResize = () => {
|
|
height.value = containerHeight + 'px';
|
|
height.value = containerHeight + 'px';
|
|
map.updateSize();
|
|
map.updateSize();
|
|
};
|
|
};
|
|
|
|
+const getMap = () => {
|
|
|
|
+ return map;
|
|
|
|
+};
|
|
|
|
+const getScale = () => {
|
|
|
|
+ return scale;
|
|
|
|
+};
|
|
|
|
+const getMapUtils = () => {
|
|
|
|
+ return mapUtils;
|
|
|
|
+};
|
|
// 加载事件
|
|
// 加载事件
|
|
onMounted(() => {
|
|
onMounted(() => {
|
|
init();
|
|
init();
|
|
@@ -141,18 +345,14 @@ onMounted(() => {
|
|
onUnmounted(() => {
|
|
onUnmounted(() => {
|
|
window.removeEventListener('resize', handleResize);
|
|
window.removeEventListener('resize', handleResize);
|
|
});
|
|
});
|
|
-const getMap = () => {
|
|
|
|
- return map;
|
|
|
|
-};
|
|
|
|
-const getScale = () => {
|
|
|
|
- return scale;
|
|
|
|
-};
|
|
|
|
|
|
+provide('getMapUtils', getMapUtils);
|
|
provide('getMap', getMap);
|
|
provide('getMap', getMap);
|
|
provide('getScale', getScale);
|
|
provide('getScale', getScale);
|
|
-defineExpose({ addMarker, clearMarker });
|
|
|
|
|
|
+defineExpose({ getMapUtils, addMarker, clearMarker });
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style scoped>
|
|
<style scoped>
|
|
|
|
+@import '../map.scss';
|
|
.map-container {
|
|
.map-container {
|
|
width: 100%;
|
|
width: 100%;
|
|
height: 100%;
|
|
height: 100%;
|