shuhao 5 mēneši atpakaļ
vecāks
revīzija
051199554e
2 mainītis faili ar 14 papildinājumiem un 11 dzēšanām
  1. 2 2
      src/utils/ol-map/Map.js
  2. 12 9
      src/views/authentic/authenticMap.js

+ 2 - 2
src/utils/ol-map/Map.js

@@ -181,10 +181,10 @@ class Map {
 		this.draw.setActive(false)
 	}
 
-	modifyDraw(callback) {
+	modifyDraw(callback, condition) {
 		this.modify = new Modify({
 			source: this.polygonLayer.source,
-			condition:callback,
+			condition:condition || function(){return true;},
 			pixelTolerance: 10, //设置吸附像素值
 
 		})

+ 12 - 9
src/views/authentic/authenticMap.js

@@ -94,6 +94,7 @@ class AuthenticMap {
   }
 
   initMap(location, target) {
+    let that = this
     let level = 16;
     let coordinate = util.wktCastGeom(location).getFirstCoordinate();
     this.kmap = new KMap.Map(
@@ -112,22 +113,24 @@ class AuthenticMap {
       }
     });
     this.kmap.modifyDraw((e) => {
-      if(e.type === "pointerdown"){
+      if(e.type === "modifyend"){
+        mapData.isEditArea = false;
+        mapData.isEditArea = true;
+      }
+    }, function(e){
         let f = null
-        this.kmap.map.forEachFeatureAtPixel(e.pixel, function (feature, layer) {
+        that.kmap.map.forEachFeatureAtPixel(e.pixel, function (feature, layer) {
           f= feature
-        });
+        },{hitTolerance:10});
+        if(!f){
+          return false
+        }
+        console.log(f)
         let res = f.get("id") === mapData.curPointData.id || !f.get("id")
         if(!res){
           ElMessage.warning("编辑中")
         }
         return res
-      }
-
-      if(e.type === "modifyend"){
-        mapData.isEditArea = false;
-        mapData.isEditArea = true;
-      }
     });
     this.kmap.addLayer(this.clickPointLayer.layer);
     this.kmap.addLayer(this.locationLayer.layer);