| 
					
				 | 
			
			
				@@ -0,0 +1,99 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import * as KMap from "@/utils/ol-map/KMap"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import * as util from "@/common/ol_common.js"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import config from "@/api/config.js"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import Style from "ol/style/Style"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import Icon from "ol/style/Icon"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { Point } from 'ol/geom'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import Feature from "ol/Feature"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import * as proj from "ol/proj"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { getArea } from 'ol/sphere.js'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import WKT from "ol/format/WKT.js"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import proj4 from "proj4" 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import { register } from "ol/proj/proj4"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+proj4.defs("EPSG:38572","+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs +type=crs"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+register(proj4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ * @description 地图层对象 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+class EditMap { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  constructor() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let that = this; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let vectorStyle = new KMap.VectorStyle(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.vectorStyle = vectorStyle; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 位置图标 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.clickPointLayer = new KMap.VectorLayer("clickPointLayer", 9999, { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      style: (f) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return new Style({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          image: new Icon({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            src: require("@/assets/img/home/garden-point.png"), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            scale: 0.5, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            anchor: [0.5, 1], 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          }), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      }, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  initMap(location, target) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let level = 16; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let coordinate = util.wktCastGeom(location).getFirstCoordinate(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.kmap = new KMap.Map(target, level, coordinate[0], coordinate[1], null, 8, 22); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let xyz2 = config.base_img_url3 + "map/lby/{z}/{x}/{y}.png"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.kmap.addXYZLayer(xyz2, { minZoom: 8, maxZoom: 22 }, 2); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.kmap.addLayer(this.clickPointLayer.layer); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.setMapPoint(coordinate) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.kmap.initDraw((e) => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      // showContent.isShow = true 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.kmap.startDraw() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.kmap.modifyDraw() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  setAreaGeometry(geometryArr) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let that = this 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    geometryArr.map(item => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      that.kmap.setLayerWkt(item.featureWkt) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  clearLayer(){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // this.kmap.removeLayer(this.clickPointLayer.layer) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.kmap.polygonLayer.source.clear(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  getAreaGeometry() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    const features = this.kmap.getLayerFeatures() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let geometryArr = [] 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let area = 0 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    // 获取图层上的Polygon,转成geoJson用于回显 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    features.forEach(item => { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      geometryArr.push({featureWkt: new WKT().writeFeature(item)}) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      let geom = item.getGeometry().clone() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      geom.transform(proj.get("EPSG:4326"), proj.get("EPSG:38572")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      let areaItem = getArea(geom) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      areaItem = (areaItem + areaItem / 2) / 1000; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      area += areaItem 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    return {geometryArr, area: area.toFixed(2)} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  setMapPosition(center) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.kmap.getView().animate({ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      center, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      zoom: 16, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      duration: 500, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.setMapPoint(center) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  setMapPoint(coordinate) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.clickPointLayer.source.clear() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    let point = new Feature(new Point(coordinate)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    this.clickPointLayer.addFeature(point) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+  } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+export default EditMap; 
			 |