彭宇 hace 2 años
padre
commit
6125c9b836
Se han modificado 1 ficheros con 5 adiciones y 2 borrados
  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);
           }
         },
       }