| | |
| | | <template> |
| | | <el-row class="wrap"> |
| | | <el-col span="2"> |
| | | <!-- <div class="p-events-auto"> |
| | | <el-button |
| | | type="primary" |
| | | class="el-button-custom" |
| | | size="small" |
| | | @click="previousGrid" |
| | | > |
| | | 上一个 |
| | | </el-button> |
| | | <el-button |
| | | type="primary" |
| | | class="el-button-custom" |
| | | size="small" |
| | | @click="nextGrid" |
| | | > |
| | | 下一个 |
| | | </el-button> |
| | | </div> --> |
| | | <el-row> |
| | | <SatelliteManage |
| | | v-show="show" |
| | | class="satellite-manage" |
| | | :gridDataList="satelliteGridStore.gridDataList" |
| | | :loading="loading" |
| | | @search="onSearch" |
| | | @row-click="handleRowClick" |
| | | @show-rank="handleRankClick" |
| | | @show-data="handleDataClick" |
| | | @change-color="handleColorClick" |
| | | ></SatelliteManage> |
| | | </el-row> |
| | | </el-col> |
| | | <el-col span="2"> |
| | | <el-row> |
| | | <CardButton |
| | | name="卫星遥测数据" |
| | | direction="right" |
| | | @click="() => (show = !show)" |
| | | ></CardButton> |
| | | </el-row> |
| | | </el-col> |
| | | <el-row justify="space-between"> |
| | | <el-row class="wrap"> |
| | | <el-col span="2"> |
| | | <el-row> |
| | | <SatelliteManage |
| | | v-show="show" |
| | | class="satellite-manage" |
| | | :gridDataList="satelliteGridStore.gridDataList" |
| | | :loading="loading" |
| | | @search="onSearch" |
| | | @row-click="handleRowClick" |
| | | ></SatelliteManage> |
| | | </el-row> |
| | | </el-col> |
| | | <el-col span="2"> |
| | | <el-row> |
| | | <CardButton |
| | | name="卫星遥测数据" |
| | | direction="right" |
| | | @click="() => (show = !show)" |
| | | ></CardButton> |
| | | </el-row> |
| | | <el-row class="flex-col"> |
| | | <GridStyleTool |
| | | @show-rank="handleRankClick" |
| | | @show-data="handleDataClick" |
| | | @change-color="handleColorClick" |
| | | @change-opacity="handleOpacityClick" |
| | | ></GridStyleTool> |
| | | </el-row> |
| | | </el-col> |
| | | </el-row> |
| | | <GridTool></GridTool> |
| | | </el-row> |
| | | <SatelliteDataMix class="data-mix" @mix-data="handleMixDataClick"> |
| | | </SatelliteDataMix> |
| | | <!-- <SatelliteDataMix class="data-mix" @mix-data="handleMixDataClick"> |
| | | </SatelliteDataMix> --> |
| | | |
| | | <!-- <el-row class="historical" justify="center"> |
| | | <SatelliteAnimation |
| | | :loading="animaLoading" |
| | |
| | | </el-row> --> |
| | | </template> |
| | | <script setup> |
| | | import { map, onMapMounted } from '@/utils/map/index_old'; |
| | | import calculate from '@/utils/map/calculate'; |
| | | import marks from '@/utils/map/marks'; |
| | | import grid from '@/utils/map/grid'; |
| | | |
| | | import { ref, onMounted } from 'vue'; |
| | | import gridApi from '@/api/gridApi'; |
| | | import SatelliteManage from './component/SatelliteManage.vue'; |
| | | import SatelliteDataMix from './component/SatelliteDataMix.vue'; |
| | | import SatelliteProxy from './SatelliteProxy'; |
| | | import moment from 'moment'; |
| | | import GridStyleTool from './component/GridStyleTool.vue'; |
| | | import { SatelliteProxy } from './SatelliteProxy'; |
| | | import { useFetchData } from '@/composables/fetchData'; |
| | | import { useSatelliteGridStore } from '@/stores/satellite-grid'; |
| | | import { useSceneStore } from '@/stores/scene'; |
| | | import { useGridStore } from '@/stores/grid-info'; |
| | | |
| | | // onMounted(() => { |
| | | // initDistrict(); |
| | | // }); |
| | | // 查询长宁区行政区划 |
| | | let polygon; |
| | | function initDistrict() { |
| | | onMapMounted(() => { |
| | | if (polygon) { |
| | | map.remove(polygon); |
| | | map.add(polygon); |
| | | map.setFitView(); |
| | | return |
| | | } |
| | | // eslint-disable-next-line no-undef |
| | | var district = new AMap.DistrictSearch({ |
| | | extensions: 'all', //返回行政区边界坐标等具体信息 |
| | | level: 'district' //设置查询行政区级别为区 |
| | | }); |
| | | district.search('长宁区', function (status, result) { |
| | | var bounds = result.districtList[0].boundaries; //获取朝阳区的边界信息 |
| | | if (bounds) { |
| | | for (var i = 0; i < bounds.length; i++) { |
| | | //生成行政区划 polygon |
| | | // eslint-disable-next-line no-undef |
| | | polygon = new AMap.Polygon({ |
| | | map: map, //显示该覆盖物的地图对象 |
| | | strokeWeight: 3, //轮廓线宽度 |
| | | path: bounds[i], //多边形轮廓线的节点坐标数组 |
| | | fillOpacity: 0.1, //多边形填充透明度 |
| | | fillColor: '#CCF3FF', //多边形填充颜色 |
| | | // strokeColor: '#ffffff' //线条颜色 |
| | | strokeColor: '#0077ff' //线条颜色 |
| | | }); |
| | | } |
| | | map.setFitView(); //将覆盖物调整到合适视野 |
| | | } |
| | | }); |
| | | }); |
| | | } |
| | | const satelliteProxy = new SatelliteProxy(); |
| | | |
| | | const gridStore = useGridStore(); |
| | | gridStore.selectedSatelliteProxy = satelliteProxy; |
| | | gridStore.pushGridClz(satelliteProxy); |
| | | |
| | | const sceneStore = useSceneStore(); |
| | | const satelliteGridStore = useSatelliteGridStore(); |
| | | |
| | | const { loading, fetchData } = useFetchData(10000); |
| | | const animaLoading = ref(true); |
| | | const show = ref(true); |
| | |
| | | // 网格数据详情 |
| | | const gridDataDetailMap = new Map(); |
| | | const gridDataDetailList = ref([]); |
| | | // 地图网格相关对象 |
| | | let mapViews; |
| | | |
| | | // 查询网格信息和遥感数据组 |
| | | function onSearch(options) { |
| | | satelliteGridStore.fetchGridCell(options.id).then(() => { |
| | | SatelliteProxy.clearText(mapViews); |
| | | drawGrid(satelliteGridStore.gridInfo); |
| | | initDistrict() |
| | | prepareGrid(satelliteGridStore.gridInfo); |
| | | satelliteProxy.drawDistrict('长宁区'); |
| | | }); |
| | | satelliteGridStore.fetchGridData(options.id).then(() => { |
| | | max = satelliteGridStore.gridDataList.length; |
| | |
| | | } |
| | | } |
| | | |
| | | function drawGrid(gridInfo) { |
| | | SatelliteProxy.clearAll(mapViews); |
| | | mapViews = SatelliteProxy.drawPolyline(gridInfo); |
| | | // mapViews = SatelliteProxy.drawPolyline([gridInfo[0]]); |
| | | } |
| | | |
| | | let index = 0; |
| | | function previousGrid() { |
| | | index--; |
| | | if (index < 0) { |
| | | index = 0; |
| | | } |
| | | SatelliteProxy.clearAll(mapViews); |
| | | mapViews = SatelliteProxy.drawPolyline([satelliteGridStore.gridInfo[index]]); |
| | | } |
| | | |
| | | function nextGrid() { |
| | | index++; |
| | | if (index > satelliteGridStore.gridInfo.length - 1) { |
| | | index = satelliteGridStore.gridInfo.length - 1; |
| | | } |
| | | SatelliteProxy.clearAll(mapViews); |
| | | mapViews = SatelliteProxy.drawPolyline([satelliteGridStore.gridInfo[index]]); |
| | | } |
| | | |
| | | // 绘制网格遥感数据值和网格颜色 |
| | | function drawTextAndColor(gridData) { |
| | | // 文本标记 |
| | | const { textViews: dataTxt, labelsLayer: dataLayer } = |
| | | SatelliteProxy.drawDataText( |
| | | mapViews.points, |
| | | gridData, |
| | | mapViews.dataTxt, |
| | | mapViews.dataLayer |
| | | ); |
| | | mapViews.dataTxt = dataTxt; |
| | | mapViews.dataLayer = dataLayer; |
| | | const { textViews: rankTxt, labelsLayer: rankLayer } = |
| | | SatelliteProxy.drawRankText( |
| | | mapViews.points, |
| | | gridData, |
| | | mapViews.rankTxt, |
| | | mapViews.rankLayer |
| | | ); |
| | | mapViews.rankTxt = rankTxt; |
| | | mapViews.rankLayer = rankLayer; |
| | | SatelliteProxy.drawColor(mapViews.gridViews, gridData); |
| | | } |
| | | |
| | | let selectedGridData; |
| | | function handleRowClick(row) { |
| | | if (gridDataDetailMap.has(row.id)) { |
| | | const gridData = gridDataDetailMap.get(row.id); |
| | | selectedGridData = gridData; |
| | | drawTextAndColor(gridData); |
| | | } else { |
| | | gridApi.fetchGridDataDetail(row.id, row.groupId).then((res) => { |
| | | gridDataDetailMap.set(row.id, res.data); |
| | | const gridData = res.data; |
| | | selectedGridData = gridData; |
| | | drawTextAndColor(gridData); |
| | | function prepareGrid(gridInfo) { |
| | | satelliteProxy.gridPrepare(gridInfo, (polygon) => { |
| | | //鼠标移入事件 |
| | | polygon.on('mouseover', () => { |
| | | polygon.setOptions({ |
| | | //修改多边形属性的方法 |
| | | strokeWeight: 2, |
| | | strokeColor: 'red' |
| | | }); |
| | | }); |
| | | } |
| | | //鼠标移出事件 |
| | | polygon.on('mouseout', () => { |
| | | polygon.setOptions({ |
| | | strokeWeight: 1, |
| | | strokeColor: 'white' |
| | | }); |
| | | }); |
| | | //鼠标点击事件 |
| | | // polygon.on('click', () => { |
| | | // const [lng, lat] = polygon.getExtData(); |
| | | // sceneStore.radius = 0.5; |
| | | // sceneStore.searchScene(lng, lat); |
| | | // }); |
| | | }); |
| | | satelliteProxy.setGridEvent('click', (e) => { |
| | | const polygon = e.target; |
| | | const { gridCell } = polygon.getExtData(); |
| | | const cellIndex = gridCell.cellIndex; |
| | | const gridDataDetail = |
| | | satelliteGridStore.selectedGridDataDetail[cellIndex - 1]; |
| | | gridStore.selectedGridCellAndDataDetail = { |
| | | gridCell, |
| | | gridDataDetail |
| | | }; |
| | | }); |
| | | } |
| | | |
| | | function drawGrid(useCustomColor) { |
| | | satelliteProxy.changeVisibility({ |
| | | showGridViews: false, |
| | | showDataTxt: false, |
| | | showRankTxt: false |
| | | }); |
| | | satelliteProxy.drawTagGrid({ |
| | | tag: satelliteGridStore.selectedGridData.id, |
| | | gridDataDetail: satelliteGridStore.selectedGridDataDetail, |
| | | useCustomColor, |
| | | useDataTxtColor: true, |
| | | extData: { |
| | | name: `卫星遥测数据 - ${moment(satelliteGridStore.selectedGridData).format('YYYY-MM-DD')}` |
| | | } |
| | | }); |
| | | } |
| | | |
| | | function handleRowClick(row) { |
| | | satelliteGridStore.fetchGridDataDetail(row, () => { |
| | | drawGrid(); |
| | | }); |
| | | } |
| | | |
| | | function handleRankClick(rankVisible) { |
| | | // rankVisible ? map.add(mapViews.rankLayer) : map.remove(mapViews.rankLayer); |
| | | rankVisible ? map.add(mapViews.rankTxt) : map.remove(mapViews.rankTxt); |
| | | satelliteProxy.changeVisibility({ showRankTxt: rankVisible }); |
| | | } |
| | | |
| | | function handleDataClick(dataVisible) { |
| | | // dataVisible ? map.add(mapViews.dataLayer) : map.remove(mapViews.dataLayer); |
| | | dataVisible ? map.add(mapViews.dataTxt) : map.remove(mapViews.dataTxt); |
| | | satelliteProxy.changeVisibility({ showDataTxt: dataVisible }); |
| | | } |
| | | |
| | | function handleColorClick(isStandardColor) { |
| | | SatelliteProxy.drawColor( |
| | | mapViews.gridViews, |
| | | selectedGridData, |
| | | !isStandardColor |
| | | ); |
| | | drawGrid(!isStandardColor); |
| | | } |
| | | |
| | | function handleOpacityClick(value) { |
| | | satelliteProxy.changeGridOpacity({ opacityValue: value }); |
| | | } |
| | | |
| | | function handleMixDataClick(gridData) { |
| | |
| | | position: absolute; |
| | | right: 0; |
| | | top: 60px; |
| | | /* color: #0552f7; */ |
| | | } |
| | | </style> |