From 332e561a4673ff96c1e1d2c0b68ff5e3dca26cfd Mon Sep 17 00:00:00 2001 From: chenzeping <ChenZeping02609@163.com> Date: 星期二, 16 三月 2021 18:06:41 +0800 Subject: [PATCH] 每次新建图层 --- src/components/panel/ToolBoxPanel.vue | 34 +++++++++++++++++++++++++--------- 1 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/components/panel/ToolBoxPanel.vue b/src/components/panel/ToolBoxPanel.vue index b1b862e..e3d5d7d 100644 --- a/src/components/panel/ToolBoxPanel.vue +++ b/src/components/panel/ToolBoxPanel.vue @@ -233,6 +233,9 @@ methods: { changeChoose (index) { this.active = index + if (this.drawLayer == null) { + this.drawLayer = this.L.layerGroup().addTo(this.map) + } }, changeSelect () { this.selectGroup = !this.selectGroup @@ -247,20 +250,30 @@ iconAnchor: [13, 16], popupAnchor: [26, -32] }) - this.drawLayer = this.map.editTools.startMarker() - this.drawLayer.setIcon(myIcon) + var drawLayer = this.map.editTools.startMarker() + drawLayer.setIcon(myIcon) + this.drawLayer.addLayer(drawLayer) + this.setLogic(drawLayer) break case '绾挎爣缁�': - this.drawLayer = this.map.editTools.startPolyline() + var drawLayerLine = this.map.editTools.startPolyline() + this.drawLayer.addLayer(drawLayerLine) + this.setLogic(drawLayerLine) break case '澶氳竟褰�': - this.drawLayer = this.map.editTools.startPolygon() + var drawLayerPolygonD = this.map.editTools.startPolygon() + this.drawLayer.addLayer(drawLayerPolygonD) + this.setLogic(drawLayerPolygonD) break case '鐭╁舰': - this.drawLayer = this.map.editTools.startRectangle() + var drawLayerPolygonJ = this.map.editTools.startRectangle() + this.drawLayer.addLayer(drawLayerPolygonJ) + this.setLogic(drawLayerPolygonJ) break case '鍦嗗舰': - this.drawLayer = this.map.editTools.startCircle() + var drawLayerPolygonY = this.map.editTools.startCircle() + this.drawLayer.addLayer(drawLayerPolygonY) + this.setLogic(drawLayerPolygonY) break case '璺濈': Measure.startMeasureLen(this.map, this.L) @@ -297,11 +310,14 @@ printerY.printMap('A4Portrait page', 'MyManualPrint') break case '鍒犻櫎': - this.map.removeLayer(this.drawLayer) + // this.map.removeLayer(this.drawLayer) + this.drawLayer.clearLayers() break } - this.drawLayer.on('dblclick', this.L.DomEvent.stop).on('dblclick', this.drawLayer.toggleEdit) - this.drawLayer.setStyle({ + }, + setLogic (layer) { + layer.on('dblclick', this.L.DomEvent.stop).on('dblclick', layer.toggleEdit) + layer.setStyle({ color: 'red', fillColor: '#ffffff', fillOpacity: 0.1, -- Gitblit v1.8.0