| 
					
				 | 
			
			
				@@ -8,6 +8,7 @@ import AMapLoader from "@amap/amap-jsapi-loader"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import eventBus from "@/api/eventBus"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { convertPointToArray } from "@/utils/index"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import { deepClone } from "@/common/commonFun"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import wellknown from 'wellknown'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import {base_img_url,base_img_url3} from "@/api/config"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const map = ref(null); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -51,7 +52,7 @@ const initMap = async () => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             // 创建地图实例 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             map.value = new AMap.Map("map-container", { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 zoom: 18, // 初始缩放级别 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                center: [113.6149629 ,23.58594117], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                center: [111.01055729572, 21.7743543], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 layers: [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     // 天地图卫星 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     new AMap.TileLayer({ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -142,12 +143,14 @@ const initData = (data) =>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         item.icon.on('click', () => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             mapEventType.value = 'click' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if(item.type === 'defalutIcon'){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                item.icon.setContent(createMarkerImg());  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                item.icon.setOffset(new window.AMap.Pixel(-18, -18)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                item.type = 'activeIcon' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                const arr = pointList.value.filter(ele => ele.id === item.id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if(arr.length===0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    pointList.value.push(item) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (startDraw.value) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    item.icon.setContent(createMarkerImg());  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    item.icon.setOffset(new window.AMap.Pixel(-18, -18)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    item.type = 'activeIcon' 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    const arr = pointList.value.filter(ele => ele.id === item.id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if(arr.length===0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        pointList.value.push(item) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 item.icon.setContent(createMarkerContent(item.color));  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -173,11 +176,30 @@ const initData = (data) =>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     setTimeout(()=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         map.value.setFitView(null, false, [0, 0, 0, 0]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     },100) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 范围 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // const p1 = [ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //     [111.00745562137854, 21.77564355219471], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //     [111.00982318507914, 21.77557930674749], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //     [111.01133652227907, 21.776531091149934], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //     [111.0125762214629, 21.775945743742568], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //     [111.01290458708189, 21.775241423284797], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //     [111.01341617119812, 21.773759019078113], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //     [111.01320915809049, 21.77329502418189], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //     [111.01209794980082, 21.772538355582128], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //     [111.01117233946951, 21.772414623609905], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //     [111.00909744947245, 21.772878618505956], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //     [111.00744610353439, 21.774094523079953], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //     [111.00745562137854, 21.77564355219471] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //     ] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // addPolygon(p1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+     
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+const startDraw = ref(false) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // 开始框选 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 const startRectangleSelection = () => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     if (mouseTool.value) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        startDraw.value = true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         mouseTool.value.rectangle({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             strokeColor: "#ffffff", // 框选区域边框颜色 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             strokeOpacity: 1, // 边框透明度 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -234,7 +256,30 @@ function getSelectPoint(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     return arr 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-defineExpose({getSelectPoint,initData,startRectangleSelection,stopDrawRectangle,clearSelection}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+function getRegionList(farmId) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    VE_API.region.list({farmId}).then(({data}) =>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        data.map(item => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            addPolygon(wktToAmapPolygon(item.wkt)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+function addPolygon(data) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    console.log('dddddd', data); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let polygon = new window.AMap.Polygon({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      path: data, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      fillColor: '#FFE17E', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      strokeOpacity: 1, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      fillOpacity: 0.1, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      strokeColor: 'rgba(255, 255, 255, 0.3)', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      strokeWeight: 1, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      strokeStyle: 'solid', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    //   strokeDasharray: [5, 5], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    map.value.add(polygon) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+defineExpose({getSelectPoint,initData,startRectangleSelection,stopDrawRectangle,clearSelection, getRegionList}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 // 组件挂载时初始化地图 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 onMounted(() => { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -244,6 +289,17 @@ onMounted(() => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 onUnmounted(()=>{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     map.value.destroy()// 销毁地图实例以释放资源 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+function wktToAmapPolygon(wkt) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const geoJSON = wellknown.parse(wkt); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    if (!geoJSON || geoJSON.type !== 'MultiPolygon') { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        console.error('Invalid WKT or not a MULTIPOLYGON'); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return []; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // MULTIPOLYGON 的坐标结构:[[[ [环1], [环2], ... ]]],取第一个环 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return geoJSON.coordinates[0][0].map(coord => [coord[0], coord[1]]); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 </script> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 <style scoped> 
			 |