CaiYuanYiTiHua/src/components/MapboxMaps/MapComponent.vue

2677 lines
77 KiB
Vue
Raw Normal View History

2024-05-27 08:25:43 +08:00
<template>
2024-08-23 08:23:32 +08:00
<div class="map-container">
<div :id="mapContainerName" @mouseover="mapmouseover" class="map-box"></div>
2024-11-15 10:45:50 +08:00
<div class="cloud-query-div" v-if="props.geomsList">
<div v-if="useCloudQuery.getIdentification" @click="initiateCloudQuery2">
2024-08-23 08:23:32 +08:00
<div class="cloud-query-icon">
2024-11-15 10:45:50 +08:00
<Loading3QuartersOutlined spin :style="{ fontSize: '20px' }" />
2024-07-31 09:58:30 +08:00
</div>
2024-11-15 10:45:50 +08:00
<div>云查询</div>
</div>
<div
v-else-if="
!useCloudQuery.getIdentification &&
useCloudQuery?.beforeId &&
props.caseno == useCloudQuery?.caseno
"
@click="initiateCloudQuery3"
>
<div class="cloud-query-icon">
<Icon icon="gis:globe-poi" :size="20" />
</div>
<div> 查看结果 </div>
</div>
<div v-else @click="initiateCloudQuery1">
<div class="cloud-query-icon">
<Icon icon="gis:globe-poi" :size="20" />
</div>
<div>云查询</div>
</div>
</div>
2024-11-15 10:45:50 +08:00
<!-- 云查询内容提示 -->
<div class="cloudqueryNotice" v-if="props.geomsList && useCloudQuery.getCloudQueryVisable">
<div class="cloudquery-title">
<div class="cloudquery-left">
<img src="/message.png" alt="" />
<span class="title-box">您有一条云查询结果请查收</span>
</div>
<div class="cloudquery-right">
<a-button type="primary" @click="initiateCloudQuery3"></a-button>
<div class="line"></div>
<CloseOutlined @click="closeCloudQuery" style="color: #fff" title="关闭" />
</div>
2024-07-31 09:58:30 +08:00
</div>
2024-08-23 08:23:32 +08:00
</div>
<!-- 云查询结果 -->
<a-modal
v-model:open="open"
:footer="false"
@cancel="closeCloudQueryModal"
:width="compare ? '1020px' : '510px'"
style="top: 20px"
:destroyOnClose="true"
>
<CloudQueryContent @changeCompare="changeCompare"/>
</a-modal>
2024-08-31 17:41:03 +08:00
2024-08-23 08:23:32 +08:00
<!-- 图层控制 -->
<div class="layer-control-center" v-if="false">
<a-collapse v-model:activeKey="activeKey" accordion expandIconPosition="end" expandIcon="">
<a-collapse-panel key="1" header="图层">
<p v-for="(item, index) in props.mapConfig.layers" class="layer-item">
<a-checkbox v-model:checked="item.checked" @change="handlerCheckboxChange(item)">{{
item.name
}}</a-checkbox>
</p>
<p v-for="(item, index) in props.mapConfig.baseLayers" class="layer-item">
<a-checkbox v-model:checked="item.checked" @change="handlerCheckboxChange(item)">{{
item.name
}}</a-checkbox>
</p>
2024-09-09 09:11:36 +08:00
</a-collapse-panel>
2024-08-23 08:23:32 +08:00
</a-collapse>
</div>
2024-08-23 08:25:26 +08:00
2024-08-23 08:23:32 +08:00
<!-- 绘图控制 -->
<div class="draw-control-center" v-show="drawing">
<div class="draw-btn" @click="handlerCancleDraw"> </div>
<div class="draw-btn" @click="handlerDrawComplete"> </div>
</div>
2024-05-30 10:13:56 +08:00
2024-08-23 08:23:32 +08:00
<!-- 根据输入坐标定位 -->
<div class="position-by-lnglat">
<a-tooltip>
<template #title>图斑定位</template>
<div class="to-location" @click="handlerToPosition()"></div>
</a-tooltip>
2024-07-02 08:57:18 +08:00
2024-08-23 08:23:32 +08:00
<a-tooltip>
<template #title>坐标定位</template>
<div class="draw-polygon" @click="LocationShow = true"></div>
</a-tooltip>
2024-07-02 08:57:18 +08:00
2024-08-31 17:41:03 +08:00
<a-popover placement="bottom" v-if="props.splitPlugin" v-model:visible="splitPanelVisible">
<template #content>
<div class="split-panel">
<p class="split-panel-item" @click="handlerDrawLineString()">线</p>
<p class="split-panel-item" @click="handlerDrawPolygon()"></p>
<a-upload
name="file"
2024-09-09 09:11:36 +08:00
:before-upload="handleImportShapeFileChange"
2024-08-31 17:41:03 +08:00
:showUploadList="false"
>
<p class="split-panel-item">导入图层分割</p>
</a-upload>
2024-09-11 17:40:48 +08:00
2025-03-21 16:08:51 +08:00
<!-- <p class="split-panel-item" >地类图斑分割</p> -->
2025-04-21 15:55:02 +08:00
<!-- <a-dropdown>
2025-04-03 15:38:27 +08:00
<p @click.prevent>地类图斑分割 <DownOutlined /></p>
2025-03-21 16:08:51 +08:00
<template #overlay>
<a-menu>
<a-menu-item @click="handlerSelectLandType('gengdi')">
<p>耕地地类分割</p>
</a-menu-item>
<a-menu-item @click="handlerSelectLandType('jianshe')">
<p>建设用地地类分割</p>
</a-menu-item>
</a-menu>
</template>
2025-04-21 15:55:02 +08:00
</a-dropdown> -->
2024-08-31 17:41:03 +08:00
</div>
</template>
<div class="split-line" ></div>
</a-popover>
2024-08-23 08:23:32 +08:00
<a-tooltip>
<template #title>线分割图斑</template>
</a-tooltip>
2024-07-02 08:57:18 +08:00
2024-08-28 08:26:37 +08:00
<a-tooltip>
<template #title>{{isShowPicture?'显示选中图片方位角':'显示全部图片方位角'}}</template>
<div :class="isShowPicture?'picture-azimuth':'picture-azimuth-active'" @click="handlerChangePictureVisible()"></div>
</a-tooltip>
2024-08-23 08:23:32 +08:00
<div class="split-polygon" @click="handlerDrawPolygon()" v-if="false"> </div>
</div>
2024-07-02 08:57:18 +08:00
2024-08-23 08:23:32 +08:00
<!-- 坐标输入框 -->
<div class="to-location-input" v-if="LocationShow">
<div class="location-operation">
<a-button type="default" size="small" @click="handlerPushLocationItem"
><PlusOutlined />添加</a-button
>
2024-08-28 08:26:37 +08:00
&nbsp;
<a-upload
name="file"
:before-upload="handleImportCoorinateChange"
:showUploadList="false"
>
<a-button
type="default"
size="small"
><CloudUploadOutlined />导入
</a-button>
</a-upload>
2024-08-23 08:23:32 +08:00
&nbsp;
2024-08-28 08:26:37 +08:00
<a-button type="default" size="small" @click="handlerClearLocationItem"
2024-08-23 08:23:32 +08:00
><ClearOutlined />清空</a-button
>
2024-08-31 17:41:03 +08:00
2024-08-23 08:23:32 +08:00
&nbsp;
<a-button
type="default"
size="small"
v-if="props.splitPlugin"
@click="onHandlerSplitPolygon"
2024-08-28 08:26:37 +08:00
><SplitCellsOutlined />分割图斑</a-button>
2024-08-23 08:23:32 +08:00
<span style="float: right">
<CloseOutlined @click="handlerLocationClose" />
</span>
</div>
2024-07-18 13:43:11 +08:00
2024-08-31 17:41:03 +08:00
<!-- <a-empty v-if="locationArrays.length == 0" /> -->
2024-08-23 08:23:32 +08:00
<div class="location-item-list-coantienr">
2024-08-31 17:41:03 +08:00
<a-table :dataSource="locationArrays" size="small" :pagination="false" >
<a-table-column-group>
<a-table-column key="lng" title="经度(Y)" data-index="lng">
<template #default="{ record }">
<a-input
v-model:value="record.lng"
@chagne="handlerLocationChange"
size="small"
/>
</template>
</a-table-column>
<a-table-column key="lat" title="纬度(X)" data-index="lat">
<template #default="{record}">
<a-input
v-model:value="record.lat"
@chagne="handlerLocationChange"
size="small"
/>
</template>
</a-table-column>
<a-table-column key="operation" title="操作" data-index="operation" width="100px">
<template #default="{record,index}">
<a-button type="default" size="small" @click="handlerLocationFlyTo(index)"
><EnvironmentOutlined
/></a-button>
&nbsp;
<a-button type="default" size="small" @click="handlerLocationRemove(index)"
><DeleteOutlined
/></a-button>
</template>
</a-table-column>
</a-table-column-group>
</a-table>
<!-- <div class="location-item" v-for="(item, index) in locationArrays" :key="index">
<a-button type="default" size="small" @click="handlerLocationFlyTo(item)"
><EnvironmentOutlined
/></a-button>
<a-input
v-model:value="item.lng"
@chagne="handlerLocationChange"
addon-before="经度"
size="small"
style="width: 140px; margin: 0px 12px"
/>
<a-input
v-model:value="item.lat"
@chagne="handlerLocationChange"
addon-before="纬度"
size="small"
style="width: 140px; margin-right: 12px"
/>
<a-button type="default" size="small" @click="handlerLocationRemove(index)"
><DeleteOutlined
/></a-button>
2024-08-31 17:41:03 +08:00
</div> -->
2024-07-02 08:57:18 +08:00
</div>
2024-06-13 09:02:01 +08:00
</div>
2024-09-13 15:47:41 +08:00
<!-- 地类选择 -->
<a-modal v-model:open="landTypeVisible" title="请选择分割依据的地类" @ok="handlerSplitByLandType">
<div style="padding:15px">
<a-table
rowKey="id"
2024-09-13 15:47:41 +08:00
:rowSelection="{type:'radio',onChange:onLandTypeChange}"
:filterMultiple="false"
:pagination="false"
:dataSource="landTypeList"
:columns="[{title: '地类名称',dataIndex: 'name',key: 'name'}]" />
</div>
</a-modal>
2024-08-23 08:23:32 +08:00
</div>
</template>
<script lang="ts" setup>
import {
onMounted,
onUnmounted,
defineProps,
defineEmits,
reactive,
ref,
defineExpose,
watch,
inject,
} from 'vue';
import { useMessage } from '@/hooks/web/useMessage';
import {
CloseOutlined,
EnvironmentOutlined,
DeleteOutlined,
CopyOutlined,
PlusOutlined,
ClearOutlined,
SplitCellsOutlined,
CloudUploadOutlined,
Loading3QuartersOutlined,
2025-03-21 16:08:51 +08:00
DownOutlined,
2024-08-23 08:23:32 +08:00
} from '@ant-design/icons-vue';
import mapboxgl, { Map, Popup } from 'mapbox-gl';
import Icon from '@/components/Icon/Icon.vue';
import CloudQueryContent from '@/components/CloudQueryContent/index.vue';
2024-08-23 08:23:32 +08:00
// 图形绘制工具类
import MapboxDraw from '@mapbox/mapbox-gl-draw';
import { generateUUID, getGeometryCenter } from './src/tool';
// 测量工具
import { SwitchLayerControl, MeasureControl } from 'mapbox-extensions';
import 'mapbox-extensions/dist/index.css';
import U from 'mapbox-gl-utils';
import 'mapbox-gl/dist/mapbox-gl.css';
import './src/index.less';
import { MapboxConfig, MapboxDefaultStyle, MapControlConfig } from './src/config';
import { MP } from './src/MP';
import { DrawingType } from '@/enums/mapEnum';
// POLYGON分割函数
import { polygonCut } from './lib/segmentation';
import { splitPolygonByLine, splitPolygonByFill,splitPolygonByMultiFill,handlerToMultiPolygonGeoJson} from './lib/splitpolygon';
2024-08-23 08:23:32 +08:00
2024-09-09 09:11:36 +08:00
// 线分割
import {chunkUtil} from './lib/chunkutil.ts';
2024-08-23 08:23:32 +08:00
// 图片切换
import { userFormFileStore } from '@/store/modules/formFileUrl';
import { storeToRefs } from 'pinia';
import {
SnapPolygonMode,
SnapPointMode,
SnapLineMode,
SnapModeDrawStyles,
SnapDirectSelect,
} from 'mapbox-gl-draw-snap-mode';
import { customDrawStyles } from './Styles/Styles';
import Drawtool from '@/views/datamaintenance/components/drawtool.vue';
2025-03-29 17:03:13 +08:00
import { WktToGeojson, GeojsonToWkt,wktCollectionToGeoJson } from './src/WktGeojsonTransform';
2024-08-23 08:23:32 +08:00
import { features } from 'process';
import { getAppEnvConfig } from '@/utils/env';
import { message, Modal } from 'ant-design-vue';
import { useCloudQueryStore } from '@/store/modules/cloudquery';
2025-03-21 09:41:18 +08:00
// 地类分割
2025-04-21 15:55:02 +08:00
import { splitAndCalTubanArea,splitTubanBackYuan } from '@/api/sys/layerManagement';
2025-03-21 09:41:18 +08:00
import { CalTubanAreaModel } from '@/api/sys/model/layerModel';
import { AddDroneTask, LoadLandType, AddDroneLandTask, LoadCloudQueryByCaseNo } from '@/api/demo/cloudQuery';
import { signal } from '@/utils/signalR';
2024-09-09 09:11:36 +08:00
// 坐标系转换
import proj4 from 'proj4'
2024-09-09 09:11:36 +08:00
2024-09-11 17:40:48 +08:00
// shp数据转换
import JSZip from 'jszip'
import shp from 'shpjs'
2024-09-09 09:11:36 +08:00
// 这里的zip为上传的zip文件
const parseZip = async(zip)=>{
// 解析zip数据为二进制数据
const jsZip = new JSZip()
const zipData = await jsZip.loadAsync(zip)
// 将zip文件转化为二进制流
const data = await zipData.generateAsync({ type: 'arraybuffer' })
return await shp(data)
}
// 文件选择
const handleImportShapeFileChange = (e)=>{
parseZip(e).then(res=>{
let geojson = JSON.parse(JSON.stringify(res))
// 绘制导入的shapgefile图斑
handlerDetails(
res,
'shapefileSource',
'shapefileLayer',
{
lineStyle: { 'line-color': '#ff0000', 'line-width': 3 },
fillStyle: { 'fill-color': '#ff0000', 'fill-opacity': 0.1 },
}
)
Modal.confirm({
title: '是否确认分割图斑?',
onCancel() {
handlerDetails(
{type:"FeatureCollection",features:[]},
'shapefileSource',
'shapefileLayer',
{
lineStyle: { 'line-color': '#ff0000', 'line-width': 3 },
fillStyle: { 'fill-color': '#ff0000', 'fill-opacity': 0.1 },
}
)
},
async onOk() {
2024-09-10 16:41:53 +08:00
// splitFeatureByFill(geojson.features[0].geometry.coordinates[0]);
splitFeatureByMultiFill(geojson);
2024-09-09 09:11:36 +08:00
handlerDetails(
{type:"FeatureCollection",features:[]},
'shapefileSource',
'shapefileLayer',
{
lineStyle: { 'line-color': '#ff0000', 'line-width': 3 },
fillStyle: { 'fill-color': '#ff0000', 'fill-opacity': 0.1 },
}
)
},
});
2024-09-13 15:47:41 +08:00
}).catch((e)=>{
createMessage.error("分割失败请检查上传的Shapefile文件压缩包数据是否正确");
})
2024-09-09 09:11:36 +08:00
}
2024-09-13 15:47:41 +08:00
const landTypeVisible = ref<boolean>(false);
const landTypeList = ref([])
const splitLandTypeForm = ref({
name:null,
code:null,
geomData:null,
caseid:null,
})
2025-04-21 15:55:02 +08:00
//
function splitMultiPolygons(str) {
let hadnlerStr = str.replace(",MULTIPOLYGON","-MULTIPOLYGON");
let result = hadnlerStr.split("-");
// 移除开头的 "MULTIPOLYGON" 和多余的括号
// const cleanedStr = str.replace(/^MULTIPOLYGON\(/, '').replace(/\)+$/, '');
// // 使用正则表达式分割多个多边形
// const polygonStrings = cleanedStr.split(/\)\),\s*MULTIPOLYGON\(\(/);
// // 重新构建每个 MULTIPOLYGON
// const result = polygonStrings.map(poly => {
// // 确保每个多边形有正确的括号结构
// const fixedPoly = poly.startsWith('((') ? poly : `((${poly}`;
// return `MULTIPOLYGON(${fixedPoly}))`;
// });
return result;
}
2024-09-11 17:40:48 +08:00
2025-03-21 09:41:18 +08:00
// 地类分割图斑
2025-03-21 16:08:51 +08:00
const handlerSelectLandType = (type)=>{
2025-03-21 09:41:18 +08:00
emit('handlerStartSpliting',true);
try{
let geom = GeojsonToWkt(JSON.parse(JSON.stringify(currentGeoJson.value.geometry)));
2025-03-29 17:03:13 +08:00
// let geom = "POLYGON ((118.309424037556 34.547670781228 , 118.309595164318 34.5475487203142 , 118.30958905415 34.5475220510643 , 118.309594872126 34.5475037441097 , 118.309650493845 34.5474667417388 , 118.309649079958 34.5474500627085 , 118.309623826 34.54738605 , 118.309575552961 34.5472698959146 , 118.309522643 34.5471425680001 , 118.309730137 34.5466727850001 , 118.309679115776 34.5465914577158 , 118.309360468678 34.5467523126098 , 118.309316608846 34.5466467673944 , 118.309288715084 34.5466132635055 , 118.309269848483 34.5467056718441 , 118.309247005657 34.5468275002474 , 118.309298402015 34.5468998358621 , 118.309285967432 34.5469646580605 , 118.309324410141 34.5469494810228 , 118.309340280529 34.5469759786143 , 118.309344087666 34.547027374972 , 118.309400751348 34.5471162294817 , 118.309323166839 34.5471455373382 , 118.309357412648 34.5473528852375 , 118.309424037556 34.547670781228 ))"
// let geom = "POLYGON((118.30942404 34.54767078,118.30959516 34.54754872,118.30958905 34.54752205,118.30959487 34.54750374,118.30965049 34.54746674,118.30964908 34.54745006,118.30962383 34.54738605,118.30957555 34.5472699,118.30952264 34.54714257,118.30973014 34.54667279,118.30967912 34.54659146,118.30936047 34.54675231,118.30931661 34.54664677,118.30928872 34.54661326,118.30928872 34.54661326,118.30926985 34.54670567,118.30924701 34.5468275,118.3092984 34.54689984,118.30928597 34.54696466,118.30932441 34.54694948,118.30934028 34.54697598,118.30934409 34.54702737,118.30940075 34.54711623,118.30932317 34.54714554,118.30935741 34.54735289,118.30942404 34.54767078,118.30942404 34.54767078))";
2025-03-21 09:41:18 +08:00
let calAreaParams = {
"wktgeom":geom,
2025-03-21 16:08:51 +08:00
"type":type
2025-03-21 09:41:18 +08:00
}
2025-03-29 17:03:13 +08:00
2025-04-21 15:55:02 +08:00
splitTubanBackYuan(calAreaParams).then(res=>{
let geojson = {
type:"FeatureCollection",
features:[]
};
let wktArray = splitMultiPolygons(res.gengdituban);
if(wktArray.length>0){
wktArray?.forEach((item,index)=>{
console.log("item",item);
let feature = {
"type": "Feature",
"properties": {
"id": generateUUID()
},
"geometry": WktToGeojson(item)
}
geojson.features.push(feature);
})
}else{
//
let feature = {
"type": "Feature",
"properties": {
"id": generateUUID()
},
"geometry": WktToGeojson(res.gengdituban)
}
}
console.log("splitTubanBackYuan",geojson)
splitFeatureByMultiFill(geojson);
handlerDetails(
{type:"FeatureCollection",features:[]},
'shapefileSource',
'shapefileLayer',
{
lineStyle: { 'line-color': '#ff0000', 'line-width': 3 },
fillStyle: { 'fill-color': '#ff0000', 'fill-opacity': 0.1 },
}
)
})
return null;
2025-03-21 09:41:18 +08:00
splitAndCalTubanArea(calAreaParams).then(res=>{
if(res){
2025-03-29 17:03:13 +08:00
2025-03-21 09:41:18 +08:00
let splitAfterFeatures = {
type: 'FeatureCollection',
features: [],
};
// 耕地
if(res.gengdituban && !res.gengdituban.match("EMPTY")){
2025-03-29 17:03:13 +08:00
// let geojsonData = wktCollectionToGeoJson(res.gengdituban);
2025-03-21 09:41:18 +08:00
let geometry = WktToGeojson(res.gengdituban)
2025-03-29 17:03:13 +08:00
// let geomtry_01 = WktToGeojson("POLYGON((118.3093166 34.5466468,118.3095756 34.5472699,118.3095226 34.5471426,118.3097301 34.5466728,118.3096917 34.5466115,118.3096791 34.5465915,118.3096252 34.5466187,118.3093605 34.5467523,118.3093166 34.5466468))");
// let geomtry_02 = WktToGeojson("POLYGON((118.3096238 34.5473861,118.3095893 34.5473029,118.309624 34.5473866,118.3096238 34.5473861))");
// let geomtry_03 = WktToGeojson("POLYGON((118.3096266 34.547393,118.3096408 34.5474354,118.3096491 34.5474501,118.3096266 34.547393))");
console.log("geomtry_01");
2025-03-21 09:41:18 +08:00
let feature = {
"type": "Feature",
"properties": {
"id": generateUUID()
},
"geometry": geometry
}
splitAfterFeatures.features.push(feature)
2025-03-29 17:03:13 +08:00
// splitAfterFeatures.features?.push({
// "type": "Feature",
// "properties": {
// "id": generateUUID()
// },
// "geometry": geomtry_01
// })
// splitAfterFeatures.features?.push({
// "type": "Feature",
// "properties": {
// "id": generateUUID()
// },
// "geometry": geomtry_02
// })
// splitAfterFeatures.features?.push({
// "type": "Feature",
// "properties": {
// "id": generateUUID()
// },
// "geometry": geomtry_03
// })
2025-03-21 09:41:18 +08:00
}
// 农用地
if(res.nongyongdituban && !res.nongyongdituban.match("EMPTY")){
let geometry = WktToGeojson(res.nongyongdituban)
let feature = {
"type": "Feature",
"properties": {
"id": generateUUID()
},
"geometry": geometry
}
splitAfterFeatures.features.push(feature)
}
// 基本农田
if(res.jibennongtiantuban && !res.jibennongtiantuban.match("EMPTY")){
let geometry = WktToGeojson(res.jibennongtiantuban)
let feature = {
"type": "Feature",
"properties": {
"id": generateUUID()
},
"geometry": geometry
}
splitAfterFeatures.features.push(feature)
}
//
if(res.remaintuban && !res.remaintuban.match("EMPTY")){
let geometry = WktToGeojson(res.remaintuban)
let feature = {
"type": "Feature",
"properties": {
"id": generateUUID()
},
"geometry": geometry
}
splitAfterFeatures.features.push(feature)
}
// 生态保护红线
if(res.shengtaihongxiantuban && !res.shengtaihongxiantuban.match("EMPTY")){
let geometry = WktToGeojson(res.shengtaihongxiantuban)
let feature = {
"type": "Feature",
"properties": {
"id": generateUUID()
},
"geometry": geometry
}
splitAfterFeatures.features.push(feature)
}
2025-03-29 17:03:13 +08:00
2025-03-21 09:41:18 +08:00
// 分割数据返回父组件中
emit('handlerSplitPolygon', splitAfterFeatures.features);
handlerUnDraw();
}
}).catch((e)=>{
emit('handlerStartSpliting',false);
})
}catch(e){
2025-03-29 17:03:13 +08:00
emit('handlerStartSpliting',false);
2025-03-21 09:41:18 +08:00
}
// let res = {
// "wktgeom": null,
// "gengdi": 0.17,
// "nongyongdi": 1.64,
// "jibennongtian": 0,
// "shengtaihongxian": 0,
// "gengdituban": "POLYGON((118.204530452946 34.6149319373947,118.204383402255 34.6149647739564,118.20439867709747 34.6150347166548,118.2045384290743 34.61501302803828,118.204530452946 34.6149319373947))",
// "nongyongdituban": "POLYGON((118.204827409679 34.6149804783991,118.204539019005 34.6150190256674,118.204530452946 34.6149319373947,118.204383402255 34.6149647739564,118.204410528111 34.615088981821,118.203870866355 34.6151889191832,118.203870866355 34.6152688690729,118.204421949524 34.6151746424171,118.204421949524 34.6151546549447,118.204847397152 34.6150918371741,118.204827409679 34.6149804783991))",
// "jibennongtiantuban": "",
// "shengtaihongxiantuban": "",
// "remaintuban": "POLYGON EMPTY"
// }
// if(res){
// let splitAfterFeatures = {
// type: 'FeatureCollection',
// features: [],
// };
// // 耕地
// if(res.gengdituban && !res.gengdituban.match("EMPTY")){
// let geometry = WktToGeojson(res.gengdituban)
// let feature = {
// "type": "Feature",
// "properties": {
// "id": generateUUID()
// },
// "geometry": geometry
// }
// splitAfterFeatures.features.push(feature)
// }
// // 农用地
// if(res.nongyongdituban && !res.nongyongdituban.match("EMPTY")){
// let geometry = WktToGeojson(res.nongyongdituban)
// let feature = {
// "type": "Feature",
// "properties": {
// "id": generateUUID()
// },
// "geometry": geometry
// }
// splitAfterFeatures.features.push(feature)
// }
// // 基本农田
// if(res.jibennongtiantuban && !res.jibennongtiantuban.match("EMPTY")){
// let geometry = WktToGeojson(res.jibennongtiantuban)
// let feature = {
// "type": "Feature",
// "properties": {
// "id": generateUUID()
// },
// "geometry": geometry
// }
// splitAfterFeatures.features.push(feature)
// }
// //
// if(res.remaintuban && !res.remaintuban.match("EMPTY")){
// let geometry = WktToGeojson(res.remaintuban)
// let feature = {
// "type": "Feature",
// "properties": {
// "id": generateUUID()
// },
// "geometry": geometry
// }
// splitAfterFeatures.features.push(feature)
// }
// // 生态保护红线
// if(res.shengtaihongxiantuban && !res.shengtaihongxiantuban.match("EMPTY")){
// let geometry = WktToGeojson(res.shengtaihongxiantuban)
// let feature = {
// "type": "Feature",
// "properties": {
// "id": generateUUID()
// },
// "geometry": geometry
// }
// splitAfterFeatures.features.push(feature)
// }
// // 分割数据返回父组件中
// emit('handlerSplitPolygon', splitAfterFeatures.features);
// handlerUnDraw();
// }
// splitAndCalTubanArea(calAreaParams).then(res=>{
// })
// splitPanelVisible.value = false;
// LoadLandType().then(res=>{
// landTypeList.value = res;
// })
// landTypeVisible.value = true;
2024-09-13 15:47:41 +08:00
}
// 使用地类分割
const handlerSplitByLandType = ()=>{
splitLandTypeForm.value.caseid = props.caseid || props.caseno;
let geojson = {
"type": "Feature",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [
[
]
]
}
}
currentGeoJson.value.geometry.coordinates[0]?.forEach((item,index)=>{
geojson.geometry.coordinates[0].push([item[0],item[1]]);
})
splitLandTypeForm.value.geomData = GeojsonToWkt(JSON.parse(JSON.stringify(geojson.geometry)));
2024-09-13 15:47:41 +08:00
landTypeVisible.value = false;
//console.log("splitLandTypeForm",splitLandTypeForm.value)
2024-09-13 15:47:41 +08:00
let paramStr = "?"
for(let key in splitLandTypeForm.value){
//console.log("key",key);
2024-09-13 15:47:41 +08:00
paramStr+=key+"="+splitLandTypeForm.value[key]+"&";
}
if (useCloudQuery.getIdentification) {
message.warning('已有地类分割运行,不能再次提交');
} else {
AddDroneLandTask(paramStr).then((res) => {
message.success('成功提交地类分割数据');
useCloudQuery.setIdentification(true);
});
}
}
const onLandTypeChange = (selectedRowKeys, selectedRows)=>{
splitLandTypeForm.value.name = selectedRows[0].name;
splitLandTypeForm.value.code = selectedRows[0].id;
2024-09-11 17:40:48 +08:00
}
2024-09-09 09:11:36 +08:00
// 投影转地理坐标系
function GkToCGCS2000(lngLat){
2024-08-31 17:41:03 +08:00
try{ // 需要根据投影度带确定转换参数
let from_system = "";
if(lngLat[0]>=37000000 && lngLat[0] < 38000000){
from_system = "+proj=tmerc +lat_0=0 +lon_0=111 +k=1 +x_0=37500000 +y_0=0 +ellps=GRS80 +units=m +no_defs +type=crs"
}if(lngLat[0]>=38000000 && lngLat[0] < 39000000){
from_system = "+proj=tmerc +lat_0=0 +lon_0=114 +k=1 +x_0=38500000 +y_0=0 +ellps=GRS80 +units=m +no_defs +type=crs"
}if(lngLat[0]>=39000000 && lngLat[0] < 40000000){ // CGCS2000 / 3-degree Gauss-Kruger zone 39
from_system = "+proj=tmerc +lat_0=0 +lon_0=117 +k=1 +x_0=39500000 +y_0=0 +ellps=GRS80 +units=m +no_defs +type=crs"
}else if(lngLat[0] >= 40000000){ // CGCS2000 / 3-degree Gauss-Kruger zone 40
from_system = "+proj=tmerc +lat_0=0 +lon_0=120 +k=1 +x_0=40500000 +y_0=0 +ellps=GRS80 +units=m +no_defs +type=crs"
}
// China Geodetic Coordinate System 2000
// let to_system = "+proj=longlat +ellps=GRS80 +no_defs +type=crs";
2024-08-31 17:41:03 +08:00
// WGS 84 -- WGS84 - World Geodetic System 1984,
let to_system = "+proj=longlat +datum=WGS84 +no_defs +type=crs";
// transform
let trasnformLnglat = proj4(from_system,to_system,lngLat);
return trasnformLnglat;
}catch(e){
return null;
}
}
2024-08-23 08:23:32 +08:00
const useCloudQuery = useCloudQueryStore();
const { VITE_GLOB_API_URL } = getAppEnvConfig();
const VITE_GLOB_API_URL_VAR = ref<String>(VITE_GLOB_API_URL + '/');
const mapContainerName = ref<String>();
mapContainerName.value = 'mapContainer-' + generateUUID();
const openModal = ref(false);
const insertShpModal = ref(false);
const changeOpenModal = (value) => {
openModal.value = value;
};
const changeOpenInsertShpModal = (value) => {
insertShpModal.value = value;
};
// map参数类型
interface MapboxOptionsInterface {
mapOptions: mapboxgl.MapboxOptions;
control: DrawingType[];
}
2024-07-02 16:34:19 +08:00
2024-08-23 08:23:32 +08:00
const props = defineProps({
mapConfig: {
type: Object,
default: {},
},
layers: {
type: Array,
default: [],
},
location: {
type: Array,
default: [],
},
type: {
type: String,
default: '',
},
feature: {
type: String,
default: '',
},
splitPlugin: {
type: Boolean,
default: false,
},
geomsList: {
type: Array,
default: null,
},
caseid: {
type: String,
default: '',
},
2024-09-04 10:16:37 +08:00
caseno: {
type: String,
default: '',
},
countyname: {
type: String,
default: '',
2024-09-04 10:16:37 +08:00
}
2024-08-23 08:23:32 +08:00
});
2024-09-13 15:47:41 +08:00
2024-08-23 08:23:32 +08:00
let nextMapControl: Array<any> = reactive([]);
nextMapControl = props.control
? props.control.map((item) => {
return MapControlConfig[item];
})
: [];
// 定义地图容器
let map: Map;
let drawTool: any;
2024-09-18 17:18:34 +08:00
let popup: Popup;
2024-08-23 08:23:32 +08:00
let clickPoisition: Array<number> = [];
let selectFeature: Object = {};
let mp: any = null;
let geojson = reactive({
geojson: {},
});
let drawing = ref(false);
2024-07-03 15:35:14 +08:00
2024-08-23 08:23:32 +08:00
let drawGeojson = reactive({
geojson: {
type: 'FeatureCollection',
features: [],
},
});
2024-07-02 16:34:19 +08:00
2024-08-23 08:23:32 +08:00
let switchLayerControler;
2024-07-03 15:35:14 +08:00
2024-08-23 08:23:32 +08:00
const { createConfirm, createMessage } = useMessage();
2024-07-03 15:35:14 +08:00
2024-08-23 08:23:32 +08:00
// 定义地图回调emit
// 地图加载完成回调
const emit = defineEmits([
'mapOnLoad',
'mapDraw',
'handlerDrawComplete',
'handlerGetFormDetail',
'handlerSplitPolygon',
2025-03-21 09:41:18 +08:00
'handlerStartSpliting',
2024-08-23 08:23:32 +08:00
'onFeatureClick',
]);
watch(
() => props.mapConfig,
(newVal, oldVal) => {
handlerLoadMapLayer();
},
);
2024-08-19 10:51:59 +08:00
const formFileStore = userFormFileStore();
const formFileState = storeToRefs(formFileStore);
2024-08-23 08:23:32 +08:00
watch(formFileState.url, (newValue, oldValue) => {});
function mapmouseover(e) {}
onMounted(() => {
2025-05-26 10:24:04 +08:00
2024-08-23 08:23:32 +08:00
// let mapDiv = window.document.getElementById(mapContainerName.value);
// mapDiv?.onmouseover = function(e){
// alert(e);
// }
2024-11-27 08:23:37 +08:00
mapboxgl.accessToken = MapboxConfig.ACCESS_TOKEN;
2024-08-23 08:23:32 +08:00
map = initMap();
map.on('load', () => {
2024-10-15 10:43:16 +08:00
2024-08-23 08:23:32 +08:00
//挂载mapbox-gl-utils
U.init(map);
mp = new MP(map);
// 根据地图配置信息加载地形数据
if (props.mapConfig.mode == '3D') {
// handlerLoadTerrain();
}
2024-08-19 10:51:59 +08:00
2024-08-23 08:23:32 +08:00
// 初始化绘图空间
// handlerInitDrawTool(null);
2024-08-10 16:52:25 +08:00
2024-08-23 08:23:32 +08:00
map.on('click', (e) => {
// handlerPreviewFeatureInfo(e);
clickPoisition = e.lngLat;
//console.log("clickPoisition",clickPoisition);
2024-08-23 08:23:32 +08:00
});
2024-08-13 11:22:15 +08:00
2024-08-23 08:23:32 +08:00
map.on('draw.selectionchange', (e) => {
// handlerCopyToTargetLayer(e);
});
2024-06-13 09:02:01 +08:00
2024-08-23 08:23:32 +08:00
emit('mapOnLoad', map);
2024-07-02 18:59:27 +08:00
2024-08-23 08:23:32 +08:00
// 设置绘图监听事件
map.on('draw.create', function (e) {
drawGeojson.geojson.features = e.features;
handlerDealFeature(e.features[0]);
});
2024-07-02 18:59:27 +08:00
2024-08-23 08:23:32 +08:00
map.on('draw.update', function (e) {
drawGeojson.geojson = e.features;
handlerDealFeature(e.features[0]);
2024-07-03 15:35:14 +08:00
});
2024-08-23 08:23:32 +08:00
map.on('draw.delete', function (e) {
handlerDeleteFeature(e.features[0]);
2024-07-03 15:35:14 +08:00
});
2024-08-23 08:23:32 +08:00
window.handlerCopyFeature = handlerCopyFeature;
// 测量工具
map.addControl(
new MeasureControl({
horizontal: true, //default false
btnBgColor: '#ffffff', //default '#ffffff'
btnActiveColor: '#ddd', //default '#ddd'
geometryClick: true, //defualt false
enableModes: ['Point', 'LineString', 'Polygon'], //default all
onStart: () => {},
onStop: () => {},
measurePointOptions: {},
measureLineStringOptions: {},
measurePolygonOptions: {},
}),
'top-right',
);
// 加载图层
handlerLoadMapLayer();
// 应用图层绑定点击事件
// applicationLayers.forEach((item,index)=>{
// map.on("click",item.layer.id,(e)=>{
// let state = findLayerAttributeInfo(applicationLayers,e.features[0].layer.id);
// if(state){
// let formDetailParams = {
// attributeTable:state.attributeTable,
// attributeField:state.attributeField,
// value:e.features[0].properties.gid
// }
// // 调用父组件查询表单详情信息
// emit("handlerGetFormDetail",formDetailParams)
// createMessage.success("数据表:"+state.attributeTable+";查询字段:"+state.attributeField+"字段值:"+e.features[0].properties.gid)
// }else{
// createMessage.warning("当前点击图层未绑定信息");
// }
// })
// })
// 分割多边形
// splitFeature();
// 添加地类分割图斑
// map.addLayer({
// id: 'yingxiang',
// type: 'raster',
// source: {
// type: 'raster',
// tiles: [
// "http://192.168.10.131:8080/geoserver/my_workspace/wms?service=WMS&version=1.1.0&request=GetMap&layers=my_workspace:geoserver371302&CQL_FILTER=dlmc='旱地'&styles=&bbox={bbox-epsg-3857}&width=256&height=256&srs=EPSG:3857&format=image/png&TRANSPARENT=TRUE",
// ],
// tileSize: 256,
// },
// layout: {
// }
// })
2024-10-15 10:43:16 +08:00
// map.addLayer(
// {
// 'id': 'geoserver371302Layer',
// 'type': 'fill',
// 'source': {
// type: 'vector',
// tiles: [VITE_GLOB_API_URL_VAR.value+'api/DroneCaseInfoSingle/QueryVectorTileByTable?z={z}&x={x}&y={y}&table=geoserver371302'],
// minzoom: 1,
// maxzoom: 20,
// 'cluster': true, // 启用聚合
// 'clusterMaxZoom': 0, // 最大聚合缩放级别
// 'clusterRadius': 0 // 聚合半径
// },
// "source-layer": "geoserver371302",
// 'layout': {
// 'line-join': 'round',
// 'line-cap': 'round',
// },
// 'paint': {
// 'line-color': "#408eff",
// 'line-width': 2
// }
// }
// )
2024-07-03 15:35:14 +08:00
});
2024-08-23 08:23:32 +08:00
});
2024-07-03 15:35:14 +08:00
2024-08-23 08:23:32 +08:00
function handlerLayerChange() {
var allLayers = map.getStyle().layers;
if (map.getLayer('detailsLayerLine'))
map.moveLayer('detailsLayerLine', allLayers[allLayers.length - 1].id);
allLayers.forEach(function (layer) {});
// allLayers.forEach(function(layer){
// //console.log("layersssss",layer.id);
2024-08-23 08:23:32 +08:00
// // map.moveLayer('detailsLayer', layer.id);
// });
}
// 地图图层控制
const handlerLoadMapLayer = () => {
if (switchLayerControler) {
// var allLayers = map.getStyle().layers;
// allLayers.forEach(function(layer){
// //console.log("layerEEEEEE",layer);
// //console.log(layer.id);
2024-08-23 08:23:32 +08:00
// // map.removeLayer(layer.id);
// });
// var allSources = Object.keys(map.style.sourceCaches);
// allSources.forEach(function(sourceId){
// map.removeSource(sourceId);
// });
map.removeControl(switchLayerControler);
2024-07-06 10:31:53 +08:00
}
2024-08-23 08:23:32 +08:00
let configlayers = {};
let baseLayers = [];
props.mapConfig.layers?.forEach((item, index) => {
let applicationLayers = [];
item?.layers?.forEach((it, idx) => {
let style = JSON.parse(it.style);
let layers = {
name: it.name,
layer: style,
fixed: true,
zoom: 18,
easeToOptions: {},
mutex: false,
mutexIdentity: generateUUID(),
active: it.checked,
backgroundImage: '',
backgroundImageActive: '',
selectAndClearAll: true,
selectAllLabel: 'select all',
clearAllLabel: 'clear all',
onVisibleChange: (visible: boolean) => {},
2024-07-03 15:35:14 +08:00
};
2024-08-23 08:23:32 +08:00
applicationLayers.push(layers);
});
configlayers[item.name] = {
uiType: 'SwitchBtn',
collapse: !0,
defaultCollapsed: !0,
layers: applicationLayers,
};
});
props.mapConfig.baseLayers?.forEach((item, index) => {
//console.log('baselayers', item);
2024-08-23 08:23:32 +08:00
let layer = JSON.parse(item.style);
let image = item.image.replace('\\', '/');
let layers = {
name: item.name,
layer: layer,
fixed: false,
// zoom:0,
easeToOptions: {},
active: item.checked,
backgroundImage: VITE_GLOB_API_URL_VAR.value + image,
backgroundImageActive: '',
onVisibleChange: (visible: boolean) => {
handlerLayerChange();
},
};
//console.log('layersssss', layers);
2024-08-23 08:23:32 +08:00
baseLayers.push(layers);
});
configlayers['地图底图'] = {
collapse: !0,
defaultCollapsed: !0,
uiType: 'ImgTxtBtn',
layers: baseLayers,
};
2024-06-08 08:34:52 +08:00
2024-08-23 08:23:32 +08:00
if (props?.mapConfig) {
if (props?.mapConfig?.baseLayers?.length > 0 && props?.mapConfig?.layers?.length > 0) {
// 图层管理工具
switchLayerControler = new SwitchLayerControl({
name: '图层管理',
position: 'top-left',
showToTop: true,
layerGroups: configlayers,
2024-06-14 08:37:42 +08:00
});
2024-08-23 08:23:32 +08:00
map.addControl(switchLayerControler, 'top-left');
}
2024-06-14 08:37:42 +08:00
}
2024-08-23 08:23:32 +08:00
handlerLayerChange();
};
// 销毁地图
const findLayerAttributeInfo = (layers, id) => {
let layer = layers?.find((itme, index) => {
return itme.layer.id == id;
2024-06-14 08:37:42 +08:00
});
2024-08-23 08:23:32 +08:00
if (layer) {
if (layer.layer.state) {
return layer.layer.state;
2024-06-14 08:37:42 +08:00
} else {
2024-08-23 08:23:32 +08:00
return false;
2024-06-14 08:37:42 +08:00
}
2024-08-23 08:23:32 +08:00
}
};
// 加载地形
const handlerLoadTerrain = () => {
map.addSource('mapbox-dem', {
type: 'raster-dem',
url: 'mapbox://mapbox.mapbox-terrain-dem-v1',
tileSize: 512,
maxzoom: 14,
});
map.setTerrain({ source: 'mapbox-dem', exaggeration: 1.5 });
};
// 移除地图实例
onUnmounted(() => {
map ? map.remove() : null;
});
// 数据绘制完成判断
const handlerDealFeature = (feature) => {
let existFeature = geojson.geojson.features.find((item, index) => {
return item.id == feature.id;
});
if (existFeature) {
// 如果查找到了 则替换数据
2024-06-14 08:37:42 +08:00
for (let i = 0; i < geojson.geojson.features.length; i++) {
if (geojson.geojson.features[i].id == feature.id) {
2024-08-23 08:23:32 +08:00
geojson.geojson.features[i] = feature;
2024-07-18 13:43:11 +08:00
}
}
2024-08-23 08:23:32 +08:00
} else {
// 如果没找到数据则添加到数组
geojson.geojson.features.push(feature);
2024-07-18 13:43:11 +08:00
}
2024-08-23 08:23:32 +08:00
// 自动将数据返回给父组件
handlerDrawComplete();
};
// 删除数据
const handlerDeleteFeature = (feature) => {
for (let i = 0; i < geojson.geojson.features.length; i++) {
if (geojson.geojson.features[i].id == feature.id) {
geojson.geojson.features.splice(i, 1);
2024-07-18 13:43:11 +08:00
}
}
2024-08-23 08:23:32 +08:00
// handlerDrawComplete();
};
// 初始化地图 返回地图实例
const initMap = () => {
return new mapboxgl.Map({
container: mapContainerName.value,
language: 'zh-cmn',
projection: 'equirectangular', // wgs84参考系
style: MapboxDefaultStyle,
// maxZoom: props.mapConfig.maxZoom ? props.mapConfig.maxZoom:18,
2025-04-21 15:55:02 +08:00
maxZoom:50,
2024-08-23 08:23:32 +08:00
minZoom: props.mapConfig.minZoom ? props.mapConfig.minZoom : 1,
zoom: props.mapConfig.zoom ? props.mapConfig.zoom : 10,
pitch: props.mapConfig.angle ? props.mapConfig.angle : 0,
center: props.mapConfig.center?.split(',')
? props.mapConfig.center?.split(',')
: [118.340253, 35.092481],
});
};
const handlerMapControlClick = (handler: string) => {
handler === 'handlerDrawPoint' && handlerDrawPoint();
handler === 'handlerDrawLineString' && handlerDrawLineString();
handler === 'handlerDrawPolygon' && handlerDrawPolygon();
};
// 使用坐标点分割图斑
const onHandlerSplitPolygon = () => {
if (locationArrays.value.length < 2) {
createMessage.warning('必须绘制2个以上点');
} else {
let feature = {
type: 'Feature',
geometry: {
type: 'LineString',
coordinates: [],
},
};
2024-07-16 11:08:51 +08:00
2024-09-13 15:47:41 +08:00
locationDrawArrays.value?.forEach((item, index) => {
2024-08-23 08:23:32 +08:00
if (item.lng && item.lat) {
let coor = [parseFloat(item.lng), parseFloat(item.lat)];
feature.geometry.coordinates.push(coor);
2024-07-16 11:08:51 +08:00
}
2024-05-27 08:25:43 +08:00
});
2024-07-16 11:08:51 +08:00
2024-08-23 08:23:32 +08:00
splitFeature(feature.geometry.coordinates);
}
};
// 分割图斑
const splitFeature = (line) => {
2024-08-28 08:26:37 +08:00
let turfSplitLine = turf.lineString(line);
let splitLineString = turf.cleanCoords(turfSplitLine);
2024-08-23 08:23:32 +08:00
let splitPolygon = currentGeoJson.value;
try {
// let features = polygonCut(splitPolygon,splitLineString,0.1,"meters");
2024-09-09 09:11:36 +08:00
splitPolygon?.geometry.coordinates[0].forEach((item,index)=>{
splitPolygon.geometry.coordinates[0][index] = [item[0],item[1]];
})
2025-03-21 09:41:18 +08:00
console.log("splitLineString",splitLineString);
let features = splitPolygonByLine(splitLineString, JSON.parse(JSON.stringify(editGeoJson.value)));
2024-09-09 09:11:36 +08:00
2024-09-13 15:47:41 +08:00
if(features){
let tempFeatures = JSON.parse(JSON.stringify(features))
let splitAfterFeatures = {
type: 'FeatureCollection',
features: [],
};
2024-06-14 08:37:42 +08:00
2024-09-13 15:47:41 +08:00
splitAfterFeatures.features = tempFeatures;
2024-09-09 09:11:36 +08:00
2025-03-21 09:41:18 +08:00
console.log("tempFeatures",tempFeatures);
2024-09-13 15:47:41 +08:00
// 分割数据返回父组件中
emit('handlerSplitPolygon', tempFeatures);
2024-12-02 16:46:48 +08:00
2024-09-13 15:47:41 +08:00
handlerUnDraw();
}else{
createMessage.warning("分割失败,请重新绘制")
handlerUnDraw();
}
2024-08-23 08:23:32 +08:00
} catch (e) {
2024-09-10 16:41:53 +08:00
console.error(e);
2024-09-09 09:11:36 +08:00
createMessage.warning('分割线起点、终点需要在图斑外,多个图斑时需要点击选择需要分割的图斑!');
2024-08-23 08:23:32 +08:00
handlerUnDraw();
}
};
// 根据面分割
const splitFeatureByFill = (fill) => {
2024-09-09 09:11:36 +08:00
2024-09-10 16:41:53 +08:00
// 去除重复点坐标
let turfPolygon = turf.polygon([fill]);
let drawPolygon = turf.cleanCoords(turfPolygon);
//console.log("drawPolygon",drawPolygon);
2024-09-10 16:41:53 +08:00
// let drawPolygon = {
// type: 'Feature',
// properties: {
// id:null,
// },
// geometry: {
// coordinates: [fill],
// type: 'Polygon',
// },
// };
2024-06-14 08:37:42 +08:00
2024-09-10 16:41:53 +08:00
let splitPolygon = currentGeoJson.value;
try{
splitPolygonByFill(drawPolygon, JSON.parse(JSON.stringify(editGeoJson.value))).then(features=>{
2024-09-10 16:41:53 +08:00
if(features){
features?.forEach((item,index)=>{
features[index].properties.id = generateUUID();
})
let tempFeatures = JSON.parse(JSON.stringify(features))
let splitAfterFeatures = {
type: 'FeatureCollection',
features: [],
};
splitAfterFeatures.features = tempFeatures;
emit('handlerSplitPolygon', tempFeatures);
handlerUnDraw();
}
})
}catch(e){
//console.log(e);
2024-09-10 16:41:53 +08:00
createMessage.warning('分割失败,请重新绘制数据!');
handlerUnDraw();
}
2024-08-23 08:23:32 +08:00
};
2024-09-10 16:41:53 +08:00
// shapefile多面分割数据
const splitFeatureByMultiFill = (geojson)=>{
2025-04-21 15:55:02 +08:00
2024-09-10 16:41:53 +08:00
let splitPolygon = currentGeoJson.value;
splitPolygonByMultiFill(geojson.features,JSON.parse(JSON.stringify(editGeoJson.value))).then(features=>{
2024-09-10 16:41:53 +08:00
if(features){
features?.forEach((item,index)=>{
features[index].properties.id = generateUUID();
})
let tempFeatures = JSON.parse(JSON.stringify(features))
let splitAfterFeatures = {
type: 'FeatureCollection',
features: [],
};
splitAfterFeatures.features = tempFeatures;
emit('handlerSplitPolygon', tempFeatures);
handlerUnDraw();
}
})
}
2024-08-23 08:23:32 +08:00
//绘制点
const handlerDrawPoint = () => {
mp.draw('Point');
mp.on('Point', function (e) {
emit('mapDraw', 'Point', e);
});
};
2024-08-31 17:41:03 +08:00
const splitPanelVisible = ref<Boolean>(false);
2024-08-23 08:23:32 +08:00
//绘制线
const handlerDrawLineString = () => {
2024-08-31 17:41:03 +08:00
splitPanelVisible.value = false;
2024-08-23 08:23:32 +08:00
mp.draw('LineString');
mp.on('LineString', function (e) {
Modal.confirm({
title: '是否确认分割图斑?',
onCancel() {
handlerUnDraw();
},
async onOk() {
let coordinates = [];
e?.forEach((item, index) => {
coordinates?.push([item.lng, item.lat]);
});
splitFeature(coordinates);
2024-06-14 08:37:42 +08:00
},
});
2024-08-23 08:23:32 +08:00
emit('mapDraw', 'LineString', e);
});
};
//绘制面
const handlerDrawPolygon = () => {
2024-08-31 17:41:03 +08:00
splitPanelVisible.value = false;
2024-08-23 08:23:32 +08:00
mp.draw('Polygon');
mp.on('Polygon', function (e) {
2024-09-09 09:11:36 +08:00
Modal.confirm({
title: '是否确认分割图斑?',
onCancel() {
handlerUnDraw();
},
async onOk() {
let coordinates = [];
e?.forEach((item, index) => {
coordinates?.push([item.lng, item.lat]);
});
coordinates.push(coordinates[0]);
splitFeatureByFill(coordinates);
handlerUnDraw();
},
2024-08-23 08:23:32 +08:00
});
emit('mapDraw', 'Polygon', e);
});
};
//删除标记
const handlerUnDraw = () => {
mp.deleteDraw();
emit('mapDraw', 'cancel');
};
// 初始化绘图空间
const handlerInitDrawTool = (feature, bool) => {
// if (feature.features.length > 0) {
// feature.features.forEach((item) => {
// if (item.geometry.type == 'MultiPolygon') {
// let arr: any = ref([]);
// item.geometry.coordinates.forEach((val) => {
// arr.value.push(val[0]);
// });
// item.geometry.coordinates = arr.value;
// item.geometry.type = 'Polygon';
// }
// });
// }
geojson.geojson = feature;
if (drawTool) {
drawTool.deleteAll();
if (feature.features) {
drawTool.set(geojson.geojson);
2024-07-04 15:53:59 +08:00
}
2024-08-23 08:23:32 +08:00
} else {
2024-05-27 08:25:43 +08:00
drawTool = new MapboxDraw({
modes: {
...MapboxDraw.modes,
draw_point: SnapPointMode,
2024-08-23 08:23:32 +08:00
draw_polygon: SnapPolygonMode,
draw_line_string: SnapLineMode,
2024-05-27 08:25:43 +08:00
direct_select: SnapDirectSelect,
},
styles: customDrawStyles,
userProperties: true,
snap: true,
snapOptions: {
2024-08-23 08:23:32 +08:00
snapPx: 12, // defaults to 15
2024-05-27 08:25:43 +08:00
snapToMidPoints: true, // defaults to false
snapVertexPriorityDistance: 0.0025, // defaults to 1.25
},
guides: false,
});
2024-08-23 08:23:32 +08:00
2024-06-13 09:02:01 +08:00
map.addControl(drawTool, 'top-right');
2024-06-11 08:29:53 +08:00
2024-08-23 08:23:32 +08:00
if (feature.features) {
drawTool.set(geojson.geojson);
2024-06-14 08:41:20 +08:00
}
2024-08-23 08:23:32 +08:00
}
2024-06-14 08:41:20 +08:00
2024-08-23 08:23:32 +08:00
// 正在绘制
// if (bool) {
// drawing.value = true;
// } else {
// drawing.value = false;
// }
2024-06-11 08:29:53 +08:00
2024-08-23 08:23:32 +08:00
drawing.value = true;
};
2024-07-19 13:57:19 +08:00
2024-08-23 08:23:32 +08:00
// 将图斑复制到指定图层
const handlerCopyToTargetLayer = (e) => {
if (e.features.length > 0) {
if (popup) {
popup.remove();
popup = null;
2024-06-11 08:29:53 +08:00
}
2024-05-30 10:13:56 +08:00
2024-08-23 08:23:32 +08:00
selectFeature = e.features[0];
2024-07-19 13:57:19 +08:00
2024-08-23 08:23:32 +08:00
popup = new mapboxgl.Popup({
closeButton: false,
closeOnClick: false,
});
2024-07-18 13:43:11 +08:00
2024-08-23 08:23:32 +08:00
// 设置 popup 的位置和内容
popup
.setLngLat(clickPoisition)
.setHTML(
`
<div style="color:#333;padding:3px 12px;cursor:pointer;" type="primary" icon="el-icon-search" onclick="handlerCopyFeature();">复制当前图斑</div>`,
2024-06-13 09:02:01 +08:00
)
2024-08-23 08:23:32 +08:00
.addTo(map);
} else {
popup.remove();
}
};
const handlerCopyFeature = () => {
popup.remove();
createMessage.success('复制成功!');
};
// 添加到图层
const handlerAddToLayerList = (layer) => {
handlerCheckLayerExist(layer);
};
// 判断图层列表中是否一定添加
const handlerCheckLayerExist = (layer) => {
for (let i = 0; i < layerList.length; i++) {
if (layerList[i] == layer.id) {
return;
2024-06-13 09:02:01 +08:00
}
2024-05-27 08:25:43 +08:00
}
2024-08-23 08:23:32 +08:00
layerList.push(layer);
};
const handlerCheckboxChange = (item) => {
//console.log('itemitemitem', item);
2024-08-23 08:23:32 +08:00
handlerPreviewLayer(item);
};
// 控制图层是否显示
const handlerPreviewLayer = (layer) => {
//console.log('layersss', layer);
2024-08-23 08:23:32 +08:00
handlerLayerControler(layer);
};
// 图层控制中心
const handlerLayerControler = (layerInfo) => {
layerInfo.layer = layerInfo.layer ? layerInfo.layer : JSON.parse(layerInfo.style);
if (map.getSource(layerInfo.layer.id)) {
if (layerInfo.checked) {
map.setLayoutProperty(layerInfo.layer.id, 'visibility', 'visible');
} else {
map.setLayoutProperty(layerInfo.layer.id, 'visibility', 'none');
}
} else {
map.addLayer(layerInfo.layer);
map.on('click', layerInfo.layer.id, function (e) {
handlerPreviewFeatureInfo(e);
});
}
};
2024-06-14 08:37:42 +08:00
2024-08-23 08:23:32 +08:00
// 查看列表数据
const handlerDataList = () => {};
2024-06-14 08:37:42 +08:00
2024-08-23 08:23:32 +08:00
// 图斑属性查看
const handlerPreviewFeatureInfo = (e) => {
if (e.features) {
isOpen.value = true;
2024-07-02 08:57:18 +08:00
}
2024-08-23 08:23:32 +08:00
};
const handlerClose = (e) => {
isOpen.value = e;
};
const currentPosition = ref(null);
// 图斑定位
const handlerLocation = (lngLat) => {
map.flyTo({
center: lngLat,
zoom: 17,
speed: 10, // 飞行速度
curve: 1, // 飞行曲线
easing(t) {
// 飞行动画函数
return t;
2024-07-02 08:57:18 +08:00
},
2024-08-23 08:23:32 +08:00
});
};
// 定位
const handlerToPosition = () => {
if (currentPosition.value) {
map.flyTo({
center: currentPosition.value,
zoom: 17,
speed: 10, // 飞行速度
curve: 1, // 飞行曲线
easing(t) {
// 飞行动画函数
return t;
},
});
}
};
// 编辑图斑
const handlerEdit = (info) => {
initDraw(info);
};
const initDraw = (layerInfo) => {
// 实例化绘图工具
drawTool = new MapboxDraw({
modes: {
...MapboxDraw.modes,
draw_point: SnapPointMode,
// draw_polygon: SnapPolygonMode,
// draw_line_string: SnapLineMode,
direct_select: SnapDirectSelect,
2024-07-02 08:57:18 +08:00
},
2024-08-23 08:23:32 +08:00
styles: customDrawStyles,
userProperties: true,
snap: true,
snapOptions: {
snapPx: 15, // defaults to 15
snapToMidPoints: true, // defaults to false
snapVertexPriorityDistance: 0.0025, // defaults to 1.25
},
guides: false,
});
2024-07-02 08:57:18 +08:00
2024-08-23 08:23:32 +08:00
map.addControl(drawTool, 'top-right');
// let geojson:Object = {};
// if (layerInfo.dataType == "面") {
// geojson.type = "Polygon";
// geojson.coordinates = geojson.coordinates[0];
// } else if (layerInfo.dataType == "点") {
// geojson.type = "Point";
// geojson.coordinates = geojson.coordinates;
// } else if (layerInfo.dataType == "线") {
// geojson.type = "LineString";
// geojson.coordinates = geojson.coordinates[0];
// }
// if (formData.lat && formData.lng) {
// formData.lat = geojson.coordinates[1];
// formData.lng = geojson.coordinates[0];
// }
// geojson = {
// type: "FeatureCollection",
// features: [
// {
// type: "Feature",
// geometry: geojson,
// },
// ],
// };
// map.setLayoutProperty("pbfLayer", "visibility", "none");
// drawTool.set(geojson);
};
const handlerDrawComplete = () => {
let arr = [];
geojson.geojson.features.forEach((item, index) => {
let wktStr = GeojsonToWkt(item.geometry);
let obj = {
columnName: 'mapgeom',
value: wktStr,
};
arr.push(obj);
});
//console.log('aaaa', arr);
2024-08-23 08:23:32 +08:00
emit('handlerDrawComplete', arr);
};
const handlerCancleDraw = () => {
2025-03-21 09:41:18 +08:00
2024-08-23 08:23:32 +08:00
if (drawTool) {
map.removeControl(drawTool);
drawTool = null;
drawing.value = false;
2024-07-02 08:57:18 +08:00
}
2024-08-23 08:23:32 +08:00
// 清空详情图层
if (map.getSource('detailsSource')) {
map.getSource('detailsSource').setData({
type: 'FeatureCollection',
features: [],
});
2024-07-02 08:57:18 +08:00
}
2024-08-23 08:23:32 +08:00
};
2024-07-02 08:57:18 +08:00
2024-08-23 08:23:32 +08:00
const handlerDraw = (status: string, features = null, bool = false) => {
let geo = {
type: 'FeatureCollection',
features: [],
};
// 清空详情图斑
if (map.getSource('detailsSource')) {
map.getSource('detailsSource').setData({
type: 'FeatureCollection',
features: [],
});
2024-07-02 08:57:18 +08:00
}
2024-08-23 08:23:32 +08:00
if (features == null) {
bool = true;
} else {
if (features.length > 0) {
for (let i = 0; i < features.length; i++) {
try {
let featureTemp = WktToGeojson(features[i]?.mapgeom);
let feature = {
id: generateUUID(),
type: 'Feature',
properties: {},
geometry: featureTemp,
};
geo.features.push(feature);
// 获取第一个图斑的中心点跳转定位
if (i == 0) {
let lngLat = getGeometryCenter(feature);
// let lngLat = getGeometryCenter(geo.features[0]);
currentPosition.value = lngLat;
handlerLocation(lngLat);
}
} catch (e) {
console.error('wktParse', e);
createMessage.error('WKT数据格式解析错误请检查WKT数据格式是否有误');
}
}
}
2024-07-02 08:57:18 +08:00
}
2024-08-23 08:23:32 +08:00
switch (status) {
case 'Add':
handlerInitDrawTool(geo, bool);
break;
case 'Edit':
handlerInitDrawTool(geo, bool);
break;
case 'Details':
handlerDetails(geo,'detailsSource',
'detailsLayer',
{
lineStyle: { 'line-color': '#fcf003', 'line-width': 3 },
fillStyle: { 'fill-color': '#fcf003', 'fill-opacity': 0.1 },
},true);
2024-08-23 08:23:32 +08:00
break;
default:
createMessage.error('请传入操作类型!');
2024-07-02 08:57:18 +08:00
}
2024-08-23 08:23:32 +08:00
};
const currentGeoJson = ref({});
const editGeoJson = ref({})
2024-08-23 08:23:32 +08:00
const handlerDetails = (
geojson,
source = 'detailsSource',
layer = 'detailsLayer',
style = {
lineStyle: { 'line-color': '#fcf003', 'line-width': 3 },
fillStyle: { 'fill-color': '#fcf003', 'fill-opacity': 0.1 },
},
isFirstLoad=false,
2024-08-23 08:23:32 +08:00
) => {
let fillLayerName = layer + 'Fill';
let lineLayerName = layer + 'Line';
2024-09-09 09:11:36 +08:00
if (source == 'detailsSource' || source == "splitPolygonSource") {
2024-08-23 08:23:32 +08:00
// 判断是单面还是多面
if(isFirstLoad){
geojson = handlerToMultiPolygonGeoJson(geojson);
}else{
2024-11-26 16:47:51 +08:00
}
let coordinates = null;
editGeoJson.value = geojson.features[0];
2024-09-09 09:11:36 +08:00
if (geojson.features.length>0 && geojson.features[0].geometry.type == 'MultiPolygon') { // 多面
// 默认取了第一个面的数据
2024-08-23 08:23:32 +08:00
coordinates = geojson.features[0].geometry.coordinates[0];
2024-09-09 09:11:36 +08:00
} else if (geojson.features.length>0 && geojson.features[0].geometry.type == 'Polygon') { // 单面
2024-08-23 08:23:32 +08:00
coordinates = geojson.features[0].geometry.coordinates;
2024-07-02 08:57:18 +08:00
}
2024-09-09 09:11:36 +08:00
// 天坑! 判读端传回的的图斑数据 最后2个坐标完全相同导致Mapbox解析不了报错
2024-08-23 08:23:32 +08:00
if (coordinates) {
2024-09-09 09:11:36 +08:00
if((coordinates[0][coordinates[0].length - 1][0] == coordinates[0][coordinates[0].length - 2][0]) && (coordinates[0][coordinates[0].length - 1][1] == coordinates[0][coordinates[0].length - 2][1])) {
2024-08-23 08:23:32 +08:00
coordinates[0]?.pop();
}
2024-07-02 08:57:18 +08:00
}
2024-09-09 09:11:36 +08:00
2024-08-23 08:23:32 +08:00
let singleFeature = {
type: 'Feature',
properties: {},
geometry: {
coordinates:[],
2024-08-23 08:23:32 +08:00
type: 'Polygon',
},
};
2024-07-02 08:57:18 +08:00
if(coordinates){
let turfPolygon = turf.polygon(coordinates);
singleFeature = turf.cleanCoords(turfPolygon);
}
// 处理清除数据重复的点数据
2024-09-09 09:11:36 +08:00
// 需要将传入的geojson处理成单面才能在分割工具中使用
currentGeoJson.value = singleFeature;
}
2024-08-23 08:23:32 +08:00
if (map.getSource(source)) {
map.getSource(source).setData(geojson);
} else {
map.addSource(source, {
type: 'geojson',
data: geojson,
});
map.addLayer({
id: fillLayerName,
type: 'fill',
source: source,
layout: {},
paint: style.fillStyle,
});
map.addLayer({
id: lineLayerName,
type: 'line',
source: source,
layout: {},
paint: style.lineStyle,
});
map.on('click', fillLayerName, function (e) {
2024-10-15 10:43:16 +08:00
// handlerPreviewFeatureInfo(e);
2024-08-23 08:23:32 +08:00
if (e.features.length > 0) {
var feature = e.features[0];
emit('onFeatureClick', feature);
2024-07-02 08:57:18 +08:00
}
2024-09-09 09:11:36 +08:00
if(fillLayerName == 'detailsLayerFill' || fillLayerName == 'detailsLayerLine'){
}
2024-08-23 08:23:32 +08:00
});
}
};
// 创建查看图斑图层
// 粘贴坐标实现定位、绘图相关
interface LocationItem {
lng: string;
lat: string;
}
const LocationShow = ref<Boolean>(false);
2024-08-31 17:41:03 +08:00
const locationColumns = ref([
{
title: '定位',
dataIndex: 'position',
key: 'position',
},
{
title: '经度',
dataIndex: 'lng',
key: 'lng',
},
{
title: '纬度',
dataIndex: 'lat',
key: 'lat',
},
{
title: '操作',
dataIndex: 'operation',
key: 'operation',
},
])
const locationArrays = ref<LocationItem[]>([]);
const locationDrawArrays = ref<LocationItem[]>();
2024-08-23 08:23:32 +08:00
const locationGeoJson = reactive({
point: {
type: 'FeatureCollection',
features: [],
},
polyline: {
type: 'FeatureCollection',
features: [],
},
polygon: {
type: 'FeatureCollection',
features: [],
},
});
const handlerPushLocationItem = () => {
let item: LocationItem = {
lng: '',
lat: '',
};
locationArrays.value.push(item);
};
2024-08-28 08:26:37 +08:00
// 通过上传txt文件方式导入坐标数据
const handleImportCoorinateChange = (e)=>{
const reader = new FileReader();
reader.readAsText(e);
reader.onload = function(text){
//console.log(text.target?.result?.split("\r\n"))
2024-08-28 08:26:37 +08:00
handlerImportCoor(text.target?.result?.split("\r\n"));
}
}
const handlerImportCoor = (arr)=>{
arr?.forEach((item,index)=>{
let coor = item.split(",");
if(coor[0] && coor[1]){
let obj = {
lng:parseFloat(coor[1]),
lat:parseFloat(coor[0])
}
locationArrays.value?.push(obj);
}
})
}
2024-08-23 08:23:32 +08:00
const handlerClearLocationItem = () => {
locationArrays.value = [];
locationGeoJson.point.features = [];
locationGeoJson.polygon.features = [];
locationGeoJson.polyline.features = [];
handlerLocationLoadLayer();
};
const handlerLocationClose = () => {
LocationShow.value = false;
};
const handlerLocationRemove = (index: number) => {
locationArrays.value.splice(index, 1);
2024-09-09 09:11:36 +08:00
locationDrawArrays.value?.splice(index, 1);
2024-08-23 08:23:32 +08:00
handlerLocationGeoJson();
};
const handlerLocationChange = (e) => {};
// 定位跳转
2024-08-31 17:41:03 +08:00
const handlerLocationFlyTo = (clickIndex:number) => {
locationDrawArrays.value = [];
locationArrays.value?.forEach((location)=>{
let obj={...location}
//console.log(obj);
2024-08-31 17:41:03 +08:00
locationDrawArrays.value?.push(obj)
})
2024-09-09 09:11:36 +08:00
2024-08-31 17:41:03 +08:00
locationDrawArrays.value?.forEach((item,index)=>{
// 坐标系转换
if(item.lng > 180){
let coor = GkToCGCS2000([parseFloat(item.lng),parseFloat(item.lat)]);
item.lng = coor[0];
item.lat = coor[1];
}
if (item.lng && item.lat) {
handlerLocationGeoJson();
}
})
// 跳转坐标
handlerLocation([locationDrawArrays.value[clickIndex].lng, locationDrawArrays.value[clickIndex].lat]);
2024-08-23 08:23:32 +08:00
};
// 处理生成geojson数据
const handlerLocationGeoJson = () => {
locationGeoJson.point.features = [];
locationGeoJson.polyline.features = [];
locationGeoJson.polygon.features = [];
2024-08-31 17:41:03 +08:00
locationDrawArrays.value?.forEach((item, index) => {
2024-08-23 08:23:32 +08:00
if (item.lng && item.lat) {
2024-07-02 08:57:18 +08:00
let feature = {
2024-08-23 08:23:32 +08:00
type: 'Feature',
geometry: {
type: 'Point',
coordinates: [parseFloat(item.lng), parseFloat(item.lat)],
},
};
locationGeoJson.point.features.push(feature);
2024-07-02 08:57:18 +08:00
}
2024-08-23 08:23:32 +08:00
});
2024-08-31 17:41:03 +08:00
if (locationDrawArrays.value?.length >= 2) {
2024-08-23 08:23:32 +08:00
let feature = {
type: 'Feature',
geometry: {
type: 'LineString',
coordinates: [],
},
};
2024-08-31 17:41:03 +08:00
locationDrawArrays.value?.forEach((item, index) => {
2024-08-23 08:23:32 +08:00
if (item.lng && item.lat) {
let coor = [parseFloat(item.lng), parseFloat(item.lat)];
feature.geometry.coordinates.push(coor);
2024-07-02 08:57:18 +08:00
}
2024-08-23 08:23:32 +08:00
});
2024-08-31 17:41:03 +08:00
2024-08-23 08:23:32 +08:00
feature.geometry.coordinates.push([
2024-08-31 17:41:03 +08:00
parseFloat(locationDrawArrays.value[0].lng),
parseFloat(locationDrawArrays.value[0].lat),
2024-08-23 08:23:32 +08:00
]);
2024-08-31 17:41:03 +08:00
2024-08-23 08:23:32 +08:00
locationGeoJson.polyline.features[0] = feature;
2024-07-02 08:57:18 +08:00
}
2024-08-31 17:41:03 +08:00
if (locationDrawArrays.value?.length >= 3) {
2024-08-23 08:23:32 +08:00
let feature = {
type: 'Feature',
geometry: {
type: 'Polygon',
2024-08-23 08:23:32 +08:00
coordinates: [[]],
},
};
2024-08-31 17:41:03 +08:00
locationDrawArrays.value?.forEach((item, index) => {
2024-08-23 08:23:32 +08:00
if (item.lng && item.lat) {
let coor = [parseFloat(item.lng), parseFloat(item.lat)];
feature.geometry.coordinates[0].push(coor);
}
});
feature.geometry.coordinates[0].push([
2024-08-31 17:41:03 +08:00
parseFloat(locationDrawArrays.value[0].lng),
parseFloat(locationDrawArrays.value[0].lat),
2024-08-23 08:23:32 +08:00
]);
locationGeoJson.polygon.features[0] = feature;
}
handlerLocationLoadLayer();
//console.log('locationGeoJson', locationGeoJson);
2024-08-23 08:23:32 +08:00
};
2024-07-02 08:57:18 +08:00
2024-08-23 08:23:32 +08:00
// 加载点、线、面图层
const handlerLocationLoadLayer = () => {
//console.log("locationGeoJson123",locationGeoJson);
2024-08-23 08:23:32 +08:00
// 绘制点
if (map.getSource('LocationPointSource')) {
map.getSource('LocationPointSource').setData(locationGeoJson.point);
} else {
map.addSource('LocationPointSource', {
type: 'geojson',
data: locationGeoJson.point,
});
map.addLayer({
id: 'LocationPointLayer',
type: 'circle',
source: 'LocationPointSource',
paint: {
'circle-radius': 5,
'circle-color': '#408eff', // 设置点的颜色
},
});
}
2024-07-02 08:57:18 +08:00
2024-08-23 08:23:32 +08:00
// 绘制线
if (map.getSource('LocationPolylineSource')) {
map.getSource('LocationPolylineSource').setData(locationGeoJson.polyline);
} else {
map.addSource('LocationPolylineSource', {
type: 'geojson',
data: locationGeoJson.polyline,
});
map.addLayer({
id: 'LocationLineLayer',
type: 'line',
source: 'LocationPolylineSource',
paint: {
'line-color': '#408eff', // 设置线的颜色
'line-width': 2, // 设置线的宽度
},
});
2024-08-19 10:51:59 +08:00
}
2024-08-23 08:23:32 +08:00
// 绘制面
if (map.getSource('LocationPolygonSource')) {
map.getSource('LocationPolygonSource').setData(locationGeoJson.polygon);
} else {
map.addSource('LocationPolygonSource', {
type: 'geojson',
data: locationGeoJson.polygon,
});
map.addLayer({
id: 'LocationPolygonLayer',
type: 'fill',
source: 'LocationPolygonSource',
paint: {
'fill-color': '#408eff', // 设置填充颜色
'fill-opacity': 0.5, // 设置填充透明度
},
});
2024-08-19 10:51:59 +08:00
}
2024-08-23 08:23:32 +08:00
};
2024-08-19 10:51:59 +08:00
// 绘制图片方位角
2024-08-28 08:26:37 +08:00
// 是否显示全部方位角
const isShowPicture = ref<Boolean>(true);
2024-08-19 10:51:59 +08:00
const imageList = ref<Array>([]);
const pictureArrowElementArray = ref([]);
const pictureArrowMarker = ref([]);
2024-08-28 08:26:37 +08:00
const pictureParentArrowElementArray = ref([]);
const currentPictureIndex = ref(null);
const currentPictureZIndex = ref(0);
2024-08-23 08:23:32 +08:00
function handlerLoadPictureAzimuth(list) {
pictureArrowMarker.value?.forEach((marker,index)=>{
if(marker){
marker.remove();
}
})
2024-08-23 08:23:32 +08:00
imageList.value = list;
pictureArrowMarker.value = [];
2024-08-23 08:23:32 +08:00
pictureArrowElementArray.value = [];
pictureParentArrowElementArray.value = [];
2024-08-23 08:23:32 +08:00
list.forEach((item, index) => {
if (item.lng && item.lat) {
let arrowElement = document.createElement('div');
arrowElement.className = 'picArrow';
arrowElement.style.width = '43px';
arrowElement.style.height = '57px';
let childElement = document.createElement('div');
childElement.className = 'childArrow';
childElement.style.width = '43px';
childElement.style.height = '57px';
childElement.style.transform = 'rotate(' + item.orientation + 'deg)';
childElement.style.backgroundImage = 'url(/map/arrow.png)';
childElement.style.backgroundSize = '43px 57px';
2024-08-28 08:26:37 +08:00
childElement.style.position = "relative";
2024-08-23 08:23:32 +08:00
arrowElement.appendChild(childElement);
pictureArrowElementArray.value?.push(childElement);
2024-08-28 08:26:37 +08:00
pictureParentArrowElementArray.value?.push(arrowElement);
2024-08-23 08:23:32 +08:00
let arrowMark = new mapboxgl.Marker(arrowElement)
.setLngLat([item.lng, item.lat])
.addTo(map);
pictureArrowMarker.value?.push(arrowMark);
2024-08-23 08:23:32 +08:00
}
});
2024-08-28 08:26:37 +08:00
currentPictureZIndex.value = list?.length;
2024-08-23 08:23:32 +08:00
// setTimeout(function(){
// handlerCurrentImageChange(0);
// },10000)
2024-08-19 10:51:59 +08:00
}
2024-08-23 08:23:32 +08:00
function handlerCurrentImageChange(fileName) {
2024-08-19 10:51:59 +08:00
// 根据图片名检索标签
let currentIndex = null;
2024-08-23 08:23:32 +08:00
imageList.value?.forEach((item, index) => {
if (item.filePath?.match(fileName)) {
2024-08-19 10:51:59 +08:00
currentIndex = index;
2024-08-28 08:26:37 +08:00
currentPictureIndex.value = index;
2024-08-19 10:51:59 +08:00
}
2024-08-23 08:23:32 +08:00
});
try {
pictureArrowElementArray.value?.forEach((itme, index) => {
pictureArrowElementArray.value[index].style.backgroundImage = 'url(/map/arrow.png)';
2024-08-28 08:26:37 +08:00
if(isShowPicture.value){
pictureArrowElementArray.value[index].style.display = 'block';
}else{
pictureArrowElementArray.value[index].style.display = 'none';
}
2024-08-23 08:23:32 +08:00
});
2024-07-02 08:57:18 +08:00
2024-08-23 08:23:32 +08:00
pictureArrowElementArray.value[currentIndex].style.backgroundImage = 'url(/map/arrow-a.png)';
2024-08-28 08:26:37 +08:00
pictureArrowElementArray.value[currentIndex].style.display = 'block';
2024-08-28 08:26:37 +08:00
// 设置显示在最上层
currentPictureZIndex.value = currentPictureZIndex.value + 1;
pictureParentArrowElementArray.value[currentIndex].style.zIndex = currentPictureZIndex.value;
2024-08-23 08:23:32 +08:00
} catch (e) {}
2024-07-02 08:57:18 +08:00
2024-08-19 10:51:59 +08:00
return;
}
2024-08-28 08:26:37 +08:00
function handlerChangePictureVisible(){
isShowPicture.value = !isShowPicture.value;
// 展示全部
if(isShowPicture.value){
pictureArrowElementArray.value?.forEach((itme, index) => {
pictureArrowElementArray.value[index].style.display = 'block';
});
}else{
pictureArrowElementArray.value?.forEach((itme, index) => {
pictureArrowElementArray.value[index].style.display = 'none';
});
if(pictureArrowElementArray.value?.length){
pictureArrowElementArray.value[currentPictureIndex.value].style.display = 'block';
}
}
// 展示选中
}
2024-08-23 08:23:32 +08:00
// 绘制点
const handlerLocationDrawPoint = () => {};
// 绘制线
const handlerLocationDrawLine = () => {};
// 绘制面
const handlerLocationDrawPolygon = () => {};
2024-09-13 15:47:41 +08:00
2024-11-15 10:45:50 +08:00
// 云查询按钮-启动
function initiateCloudQuery1() {
let geomidStr = props.geomsList.map((item) => item.key).join(',');
2024-11-15 10:45:50 +08:00
AddDroneTask({ geomid: geomidStr, caseno: props.caseno, countyname: props.countyname }).then(
(res) => {
if (res) {
message.success('成功提交云查询');
2024-10-15 17:08:44 +08:00
useCloudQuery.setGeomid(geomidStr);
useCloudQuery.setCaseno(props.caseno);
2024-10-07 16:50:56 +08:00
useCloudQuery.setIdentification(true);
2024-11-15 10:45:50 +08:00
let expires =
'; expires=' + new Date(new Date().getTime() + 60 * 60 * 1000).toUTCString();
document.cookie = 'geomid=' + encodeURIComponent(geomidStr) + expires + '; path=/';
document.cookie = 'caseno=' + encodeURIComponent(props.caseno) + expires + '; path=/';
document.cookie = 'identification=true' + expires + '; path=/';
} else {
message.error('提交云查询失败');
useCloudQuery.setIdentification(false);
}
2024-11-15 10:45:50 +08:00
},
);
}
// 云查询按钮-查询中
function initiateCloudQuery2() {
let geomidStr = props.geomsList.map((item) => item.key).join(',');
// 查看当前后台云查询图斑的情况
LoadCloudQueryByCaseNo({
geomid: useCloudQuery.geomid,
caseno: useCloudQuery.caseno,
}).then((res) => {
if (res) {
if (geomidStr == useCloudQuery.geomid && props.caseno == useCloudQuery.caseno) {
if (res.state == 1 || res.state == 0) {
message.warning('当前图斑的云查询正在运行,请稍候等待');
} else {
useCloudQuery.setIdentification(false);
useCloudQuery.setBeforeId(res.queryId);
useCloudQuery.setCloudQueryInfo({ id: res.queryId });
let expires =
'; expires=' + new Date(new Date().getTime() + 60 * 60 * 1000).toUTCString();
document.cookie = 'beforeId=' + encodeURIComponent(res.queryId) + expires + '; path=/';
open.value = true;
}
} else {
// 非当前后台云查询的图斑
message.warning('已有云查询运行,不能再次提交');
}
}
});
}
// 云查询按钮-查看结果
function initiateCloudQuery3() {
open.value = true;
}
// 云查询内容提示---------------------------------------------------------
function closeCloudQuery() {
useCloudQuery.setCloudQueryVisable(false);
useCloudQuery.identification = false;
}
2024-08-23 08:23:32 +08:00
//接口推送
2024-10-25 15:21:41 +08:00
signal.on('RevMsg', (user, cloudDataString, time, id, issystem) => {
// CloudQuery 云查询
if (user == 'CloudQuery') {
2024-10-25 15:21:41 +08:00
let cloudData = JSON.parse(cloudDataString);
2024-11-15 10:45:50 +08:00
if (
cloudData.geomid == useCloudQuery.getGeomid &&
cloudData.caseno == useCloudQuery.getCaseno
) {
if (useCloudQuery.beforeId == '' || cloudData.queryid != useCloudQuery.beforeId) {
let expires =
'; expires=' + new Date(new Date().getTime() + 24 * 60 * 60 * 1000).toUTCString();
document.cookie =
'beforeId=' + encodeURIComponent(cloudData.queryId) + expires + '; path=/';
2024-10-25 15:21:41 +08:00
}
useCloudQuery.setBeforeId(cloudData.queryid);
}
}
});
const compare = ref(false);
const open = ref(false);
const changeCompare = (value) => {
compare.value = value;
};
const closeCloudQueryModal = () => {
open.value = false;
compare.value = false;
}
2024-08-23 08:23:32 +08:00
defineExpose({
handlerDraw,
handlerDetails,
handlerLocation,
handlerCancleDraw,
handlerLoadPictureAzimuth,
handlerCurrentImageChange,
});
</script>
<style scoped>
.cloud-query-div {
position: absolute;
top: 50px;
left: 10px;
width: 66px;
height: 66px;
2024-08-23 08:23:32 +08:00
background: #fff;
display: flex;
align-items: center;
justify-content: center;
padding: 5px;
border-radius: 5px;
box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
user-select: none;
cursor: pointer;
}
.cloud-query-icon {
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 8px;
}
.map-container {
width: 100%;
height: 100%;
}
2024-07-02 08:57:18 +08:00
2024-08-23 08:23:32 +08:00
.map-box {
width: 100%;
height: 100%;
}
2024-07-02 08:57:18 +08:00
2024-08-23 08:23:32 +08:00
.layer-control-center {
position: absolute;
top: 15px;
left: 15px;
background: #fff;
border-radius: 8px;
}
2024-06-12 13:37:35 +08:00
2024-08-23 08:23:32 +08:00
.layer-control-center p {
margin: 0px;
}
2024-06-12 17:28:10 +08:00
2024-08-23 08:23:32 +08:00
.layer-control-center .ant-checkbox-wrapper {
}
2024-05-30 10:13:56 +08:00
2024-08-23 08:23:32 +08:00
.draw-control-center {
position: absolute;
padding: 8px;
top: 15px;
right: 15px;
background: #ffffff;
border-radius: 12px;
}
2024-06-14 08:37:42 +08:00
2024-08-23 08:23:32 +08:00
.draw-control-center .draw-btn {
float: left;
margin: 0px 7px;
padding: 5px;
border-radius: 5px;
}
2024-06-14 08:37:42 +08:00
2024-08-23 08:23:32 +08:00
.draw-control-center .draw-btn:hover {
background-color: rgb(0 0 0/5%);
cursor: pointer;
}
2024-06-14 08:37:42 +08:00
2024-08-23 08:23:32 +08:00
.mapboxgl-ctrl-group:not(:empty) {
box-shadow: none;
}
2024-06-14 08:37:42 +08:00
2024-08-23 08:23:32 +08:00
.mapboxgl-ctrl-group {
padding: 6px;
border-radius: 12px;
top: 5px;
right: 0px;
}
.mapbox-gl-draw_ctrl-draw-btn {
width: 20px !important;
height: 20px !important;
float: left;
}
2024-05-30 10:13:56 +08:00
2024-08-23 08:23:32 +08:00
.mapboxgl-ctrl-top-right {
width: 360px;
}
2024-06-14 08:37:42 +08:00
2024-08-23 08:23:32 +08:00
.mapboxgl-ctrl-group button + button {
border: 0px;
margin: 0px 6px;
}
2024-06-14 08:37:42 +08:00
2024-08-23 08:23:32 +08:00
.mapbox-gl-draw_ctrl-draw-btn:hover {
transform: scale(1.2);
}
2024-06-14 08:37:42 +08:00
2024-08-23 08:23:32 +08:00
.mapbox-gl-draw_polygon {
background-image: url(/polygon.png);
background-size: 100% 100%;
width: 100px;
height: 100px;
}
.mapbox-gl-draw_point {
background-image: url(/point.png);
background-size: 100% 100%;
width: 100px;
height: 100px;
}
.mapbox-gl-draw_line {
background-image: url(/line.png);
background-size: 100% 100%;
width: 100px;
height: 100px;
margin: 0px 6px;
}
2024-06-14 08:37:42 +08:00
2024-08-23 08:23:32 +08:00
.mapbox-gl-draw_trash {
background-image: url(/del.png);
background-size: 100% 100%;
width: 100px;
height: 100px;
}
2024-06-14 08:37:42 +08:00
2024-08-23 08:23:32 +08:00
.mapbox-gl-draw_combine {
background-image: url(/combine.png);
background-size: 100% 100%;
width: 100px;
height: 100px;
}
2024-06-13 18:02:33 +08:00
2024-08-23 08:23:32 +08:00
.mapbox-gl-draw_uncombine {
background-image: url(/uncombine.png);
background-size: 100% 100%;
width: 100px;
height: 100px;
}
2024-06-13 18:02:33 +08:00
2024-08-23 08:23:32 +08:00
.jas-ctrl-measure {
position: relative;
top: 6px;
right: 10px;
}
2024-06-13 18:02:33 +08:00
2024-08-23 08:23:32 +08:00
.jas-ctrl-measure-item {
height: 22px;
color: rgb(255, 255, 255);
}
2024-06-13 18:02:33 +08:00
2024-08-23 08:23:32 +08:00
.layer-item {
padding: 8px 16px;
}
2024-06-12 17:28:10 +08:00
2024-08-23 08:23:32 +08:00
.layer-item:hover {
background: #c7dcf580;
}
2024-06-13 18:02:33 +08:00
2024-08-23 08:23:32 +08:00
::v-deep .ant-collapse-content-box {
padding: 0px !important;
}
2024-06-13 18:02:33 +08:00
2024-08-23 08:23:32 +08:00
::v-deep .jas-ctrl-extend-desktop-container {
width: 320px !important;
}
2024-07-02 08:57:18 +08:00
2024-08-23 08:23:32 +08:00
.position-by-lnglat {
height: 29px;
background: #fff;
position: absolute;
top: 10px;
right: 131px;
border-radius: 3px;
box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.1);
.to-location {
width: 29px;
height: 29px;
float: left;
background: url(/map/location.png);
background-size: 20px 20px;
background-repeat: no-repeat;
background-position: 4px 5px;
&:hover {
cursor: pointer;
2024-07-02 08:57:18 +08:00
}
2024-08-23 08:23:32 +08:00
}
2024-07-02 08:57:18 +08:00
2024-11-15 10:45:50 +08:00
.picture-azimuth {
2024-08-28 08:26:37 +08:00
width: 29px;
height: 29px;
float: left;
background: url(/map/is_show_picture.png);
background-size: 20px 20px;
background-repeat: no-repeat;
background-position: 4px 5px;
&:hover {
cursor: pointer;
}
}
2024-11-15 10:45:50 +08:00
.picture-azimuth-active {
2024-08-28 08:26:37 +08:00
width: 29px;
height: 29px;
float: left;
background: url(/map/not_show_picture.png);
background-size: 20px 20px;
background-repeat: no-repeat;
background-position: 4px 5px;
&:hover {
cursor: pointer;
}
}
2024-08-23 08:23:32 +08:00
.draw-polygon {
width: 29px;
height: 29px;
float: left;
background: url(/map/draw_polygon.png);
background-size: 20px 20px;
background-repeat: no-repeat;
background-position: 4px 5px;
&:hover {
cursor: pointer;
2024-07-02 08:57:18 +08:00
}
2024-08-23 08:23:32 +08:00
}
2024-07-15 17:36:21 +08:00
2024-08-23 08:23:32 +08:00
.split-line {
width: 29px;
height: 29px;
float: left;
background: url(/map/split_polygon.png);
background-size: 20px 20px;
background-repeat: no-repeat;
background-position: 4px 5px;
&:hover {
cursor: pointer;
2024-07-15 17:36:21 +08:00
}
2024-08-23 08:23:32 +08:00
}
2024-07-18 13:43:11 +08:00
2024-08-23 08:23:32 +08:00
.split-polygon {
width: 29px;
height: 29px;
float: left;
background: url(/map/split_polygon_polygon.png);
background-size: 20px 20px;
background-repeat: no-repeat;
background-position: 4px 5px;
&:hover {
cursor: pointer;
2024-07-18 13:43:11 +08:00
}
2024-07-02 08:57:18 +08:00
}
2024-08-23 08:23:32 +08:00
}
2024-07-02 08:57:18 +08:00
2024-08-23 08:23:32 +08:00
.to-location-input {
padding: 16px;
2024-11-15 10:45:50 +08:00
padding-right: 4px;
width: 418px;
2024-08-23 08:23:32 +08:00
min-height: 60px;
background: #fff;
position: absolute;
top: 48px;
right: 10px;
2024-11-15 10:45:50 +08:00
z-index: 999999;
2024-08-23 08:23:32 +08:00
border-radius: 5px;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
.location-operation {
width: 100%;
height: 40px;
border-bottom: 1px solid #f1f1f1;
margin-bottom: 12px;
}
2024-11-15 10:45:50 +08:00
.location-item-list-coantienr {
width: 100%;
max-height: 400px;
overflow-y: auto;
.location-item {
line-height: 20px;
margin-bottom: 6px;
}
2024-07-02 08:57:18 +08:00
}
2024-08-23 08:23:32 +08:00
}
2024-08-31 17:41:03 +08:00
2024-11-15 10:45:50 +08:00
.split-panel-item:hover {
cursor: pointer;
color: #999;
}
2024-08-31 17:41:03 +08:00
2024-11-15 10:45:50 +08:00
.cloudqueryNotice {
background: rgba(0, 0, 0, 0.53);
padding: 0px 14px;
border-radius: 6px;
position: fixed;
top: 20px;
right: 5vw;
width: 700px;
color: #fff;
z-index: 10;
.cloudquery-title {
height: 40px;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 16px;
}
.cloudquery-left {
display: flex;
align-items: center;
}
.cloudquery-right {
display: flex;
align-items: center;
justify-content: space-around;
width: 130px;
}
img {
width: 34px;
height: 29px;
}
.cloudquery-btn {
display: flex;
justify-content: flex-end;
}
.line {
background: #ededed;
width: 1px;
height: 20px;
}
.anticon.anticon-close {
height: 30px;
}
button {
width: 70px;
height: 26px;
background: linear-gradient(-74deg, #086dec, #0b4bdd);
box-shadow: 3px 4px 5px 1px rgba(13, 13, 13, 0.05);
border-radius: 16px;
display: flex;
align-items: center;
justify-content: center;
}
.title-box {
margin-left: 10px;
font-size: 14px;
}
2024-08-31 17:41:03 +08:00
}
2024-08-23 08:23:32 +08:00
</style>