From d5fb65532736b996aa3176423e11e8fb114bce90 Mon Sep 17 00:00:00 2001 From: 李红刚 <p-honggang.li@pcitc.com> Date: 星期三, 17 三月 2021 14:41:44 +0800 Subject: [PATCH] 修改标绘绘制圆出现中心点BUG及同时清楚多个 --- src/components/panel/ToolBoxPanel.vue | 44 +++++++++++++++++++++++--------------------- 1 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/components/panel/ToolBoxPanel.vue b/src/components/panel/ToolBoxPanel.vue index 8d942da..ec51eff 100644 --- a/src/components/panel/ToolBoxPanel.vue +++ b/src/components/panel/ToolBoxPanel.vue @@ -242,6 +242,7 @@ ], selectGroup: false, drawLayer: null, + drawLayerArray: [], map: null, // L: window.L, active: -1, @@ -284,7 +285,7 @@ }, changeChoose (index) { this.active = index - if (this.drawLayer == null) { + if (this.drawLayer == null && index === 0) { this.drawLayer = this.L.layerGroup().addTo(this.map) } }, @@ -298,33 +299,34 @@ iconAnchor: [13, 16], popupAnchor: [26, -32] }) - var drawLayerMarker = this.map.editTools.startMarker() - drawLayerMarker.setIcon(myIcon) - this.drawLayer.addLayer(drawLayerMarker) - this.setLogic(drawLayerMarker) + this.drawLayer = this.map.editTools.startMarker() + this.drawLayer.setIcon(myIcon) + this.drawLayerArray.push(this.drawLayer) break case '绾挎爣缁�': - var drawLayerLine = this.map.editTools.startPolyline() - this.drawLayer.addLayer(drawLayerLine) - this.setLogic(drawLayerLine) + this.drawLayer = this.map.editTools.startPolyline() + this.drawLayerArray.push(this.drawLayer) + this.setLogic() break case '澶氳竟褰�': - var drawLayerPolygonD = this.map.editTools.startPolygon() - this.drawLayer.addLayer(drawLayerPolygonD) - this.setLogic(drawLayerPolygonD) + this.drawLayer = this.map.editTools.startPolygon() + this.drawLayerArray.push(this.drawLayer) + this.setLogic() break case '鐭╁舰': - var drawLayerPolygonJ = this.map.editTools.startRectangle() - this.drawLayer.addLayer(drawLayerPolygonJ) - this.setLogic(drawLayerPolygonJ) + this.drawLayer = this.map.editTools.startRectangle() + this.drawLayerArray.push(this.drawLayer) + this.setLogic() break case '鍦嗗舰': - var drawLayerPolygonY = this.map.editTools.startCircle() - this.drawLayer.addLayer(drawLayerPolygonY) - this.setLogic(drawLayerPolygonY) + this.drawLayer = this.map.editTools.startCircle() + this.drawLayerArray.push(this.drawLayer) + this.setLogic() break case '鍒犻櫎': - this.drawLayer.clearLayers() + for (let i = 0; i < this.drawLayerArray.length; i++) { + this.map.removeLayer(this.drawLayerArray[i]) + } break case '娓呴櫎': Measure.clearMeasure(this.map, this.L) @@ -365,9 +367,9 @@ break } }, - setLogic (layer) { - layer.on('dblclick', this.L.DomEvent.stop).on('dblclick', layer.toggleEdit) - layer.setStyle({ + setLogic () { + this.drawLayer.on('dblclick', this.L.DomEvent.stop).on('dblclick', this.drawLayer.toggleEdit) + this.drawLayer.setStyle({ color: 'red' }) }, -- Gitblit v1.8.0