From 8940e0a8f642e280613ab81cc2108cfcdf59da4a Mon Sep 17 00:00:00 2001 From: helloxujingliang <3225043@qq.com> Date: Tue, 21 May 2024 09:10:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/MapboxMaps/MapComponent.vue | 42 +++++++++++----------- src/views/dashboard/analysis/index.vue | 4 +-- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/src/components/MapboxMaps/MapComponent.vue b/src/components/MapboxMaps/MapComponent.vue index dd17a62a..9a22851f 100644 --- a/src/components/MapboxMaps/MapComponent.vue +++ b/src/components/MapboxMaps/MapComponent.vue @@ -93,12 +93,10 @@ let nextMapControl: Array = reactive([]); nextMapControl = props.control ? props.control.map((item) => { - console.log('item::: ', item); return MapControlConfig[item]; }) : []; - console.log('nextMapControl::: ', nextMapControl); // 定义地图容器 let map: Map; @@ -141,12 +139,10 @@ // 设置绘图监听事件 map.on("draw.create", function (e) { - console.log(e); drawGeojson.geojson = e.features[0] }); map.on("draw.update", function (e) { - console.log(e); drawGeojson.geojson = e.features[0] }); @@ -265,7 +261,6 @@ } const handlerCopyFeature = () => { - console.log("selectFeature",selectFeature); popup.remove(); createMessage.success("复制成功!") } @@ -297,7 +292,6 @@ // 图层控制中心 const handlerLayerControler = (layerInfo)=>{ - console.log("layerinfoinfo",layerInfo) if(map.getSource(layerInfo.layer.id)){ if(layerInfo.checked){ map.setLayoutProperty(layerInfo.layer.id, "visibility", "visible"); @@ -320,7 +314,6 @@ // 图斑属性查看 const handlerPreviewFeatureInfo = (e) => { if(e.features){ - console.log("EEEEEEE",e.features[0].layer.id,e.features[0].properties); isOpen.value = true; } } @@ -413,23 +406,32 @@ } const handlerDraw = (feature=null) =>{ - let featureTemp = WktToGeojson(feature); - console.log("传入的WKT:::",featureTemp); + - - let geo = { - type: "FeatureCollection", - features: [ - { - "id": "cd1d93c0e4a6747ff597f190c311d0e3", - "type": "Feature", - "properties": {}, - "geometry": featureTemp + + let geo = {}; + + if(feature==null){ + geo = { + type: "FeatureCollection", + features: [], + } + }else{ + let featureTemp = WktToGeojson(feature); + geo = { + type: "FeatureCollection", + features: [ + { + "id": "cd1d93c0e4a6747ff597f190c311d0e3", + "type": "Feature", + "properties": {}, + "geometry": featureTemp + } + ], } - ], } + - console.log("geo",geo); handlerInitDrawTool(geo) } diff --git a/src/views/dashboard/analysis/index.vue b/src/views/dashboard/analysis/index.vue index acabad5a..4f6f25a6 100644 --- a/src/views/dashboard/analysis/index.vue +++ b/src/views/dashboard/analysis/index.vue @@ -70,7 +70,7 @@ // 图斑数据 // const feature ="LINESTRING (118.55483239594203 35.81329409678203, 118.54889167836416 35.806406839795216, 118.55647247134772 35.80285975465173, 118.56157492816281 35.803303140294986)" - const feature = "POLYGON ((118.54774514802972 35.80786133598188, 118.54515277045988 35.79816597053564, 118.55919536113471 35.80085134034624, 118.56021460056033 35.80462789316549, 118.5595188628206 35.80695604583504, 118.5580066425723 35.80815336506183, 118.54774514802972 35.80786133598188))" + // const feature = "POLYGON ((118.54774514802972 35.80786133598188, 118.54515277045988 35.79816597053564, 118.55919536113471 35.80085134034624, 118.56021460056033 35.80462789316549, 118.5595188628206 35.80695604583504, 118.5580066425723 35.80815336506183, 118.54774514802972 35.80786133598188))" // 绘图完成返回geom const handlerDrawComplete = (geom)=>{ console.log("绘制完成返回的图斑",geom); @@ -84,7 +84,7 @@ // 添加图斑 // MapboxComponent.value.handlerDraw() // 编辑图斑 - MapboxComponent.value.handlerDraw(feature) + MapboxComponent.value.handlerDraw() },3000) // 图斑定位