瀏覽代碼

测量工具

彭宇 2 年之前
父節點
當前提交
6125c9b836
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      src/components/supermap.vue

+ 5 - 2
src/components/supermap.vue

@@ -35,6 +35,7 @@
         latLngLayers: [],
         latLngGroup: [],
         isEditableLayers: false,
+        drawControl: null,
       }
     },
     watch: {
@@ -58,8 +59,8 @@
                 remove: true
               }
             };
-            let drawControl = new window.L.Control.Draw(options);
-            this.map.addControl(drawControl);
+            this.drawControl = new window.L.Control.Draw(options);
+            this.map.addControl(this.drawControl);
             this.map.on(window.L.Draw.Event.CREATED, function (e) {
               let editableLayer = e.layer;
               let layerType = e.layerType;
@@ -85,6 +86,8 @@
               })
               editableLayers.addLayer(editableLayer);
             });
+          }else{
+            this.map.removeControl(this.drawControl);
           }
         },
       }