diff --git a/src/components/CMap/components/cmapSmart.vue b/src/components/CMap/components/cmapSmart.vue index 8146911..5e35283 100644 --- a/src/components/CMap/components/cmapSmart.vue +++ b/src/components/CMap/components/cmapSmart.vue @@ -21,13 +21,9 @@ wellObj: { // 井对象 type: Object, default: function() { - return { wellCode: '', id: '', lat: 39.9, lng: 116.4, radius: 10 } + return { wellCode: '', id: '', coordinateY: 39.9, coordinateX: 116.4, radius: '0' } } }, - valves: { // 阀门 - type: Array, - default: () => [] - }, zoom: { // 缩放层级 type: Number, default: 12 @@ -65,22 +61,26 @@ default: function() { return [0, -15] } + }, + valves: { // 阀门原始数据 + type: Array, + default: () => [] + }, + closeAreas: { // 关阀影响区域原始数据 + type: Array, + default: () => { + return [] + } } }, data() { return { - // wellObj: null, affectCicle: null, // 影响区域 - affectPipes: null, // 影响管线 - closeCircle: null, // 关阀影响区域 - closePipes: null, // 影响管线 mapLayers: null, // 地图图层 wellOverlay: null, // 井overlay - affectAreaOverlay: null, // 影响区域overlay - affectLineOverlays: [], // 影响管线overlay + affectAreaOverlay: [], // 影响区域overlay valvesOverlays: [], // 阀门overlay列表 - closeAreaOverlay: null, // 关阀影响区域overlay - closeLineOverlays: [] // 关阀影响区域overlay + closeAreaOverlays: [] // 关阀影响区域overlay } }, watch: { @@ -114,9 +114,20 @@ const { mapLayers } = this mapLayers.setMaxZoom(val) }, - alarmMarkers(val) { - console.log('alarmMarkers') - this.renderMarkers() + wellObj(val) { + if (val == null) { + this.removeOverlays() + } else { + this.renderAffectAP() + } + }, + valves(val) { + console.log('renderValves') + this.renderValves() + }, + closeAreas(val) { + console.log('renderValves') + this.renderCloseArea() } }, mounted() { @@ -197,8 +208,8 @@ this.$emit('ready', { mapLayers: this.mapLayers }) // this.renderMarkers() }, - renderAffectAP(wellObj) { - // this.wellObj = wellObj + // 渲染影响区域 + renderAffectAP() { const { mapLayers } = this if (!mapLayers) { return @@ -207,43 +218,29 @@ // 渲染井 if (this.wellObj != null) { this.affectCircle = { - lat: this.wellObj.lat, - lng: this.wellObj.lng, - radius: this.wellObj.radius - } - if (this.wellObj.affectPipes) { - this.affectPipes = this.wellObj.affectPipes + lat: this.wellObj.coordinateY, + lng: this.wellObj.coordinateX, + radius: parseFloat(this.wellObj.radius) } this.renderWell() - } - // 当影响区域不为空的时候显示影响区域 - if (this.affectCircle != null) { - this.renderAffectArea() - } - // 渲染管线 - if (this.affectPipes && this.affectPipes.length > 0) { - this.renderAffectPipes() + // 当影响区域不为空的时候显示影响区域 + if (this.affectCircle != null) { + this.renderAffectArea() + } } }, + // 移除影响区域 removeAffectAP() { - // 移除井 - // if (this.wellObj != null) { - // this.removeWell() - // } // 移除影响区域 if (this.affectArea != null) { this.removeAffectArea() } - // 移除管线 - if (this.affectPipes.length > 0) { - this.removeAffectPipes() - } }, // 渲染影响区域 renderAffectArea() { const { mapLayers, affectCircle } = this // 绘制影响区域 - const opts = { color: '#c45366', weight: 2, opacity: 0.9, fill: true, fillColor: '#009900', fillOpacity: 0.4 } + const opts = { color: '#boacfc', weight: 0, opacity: 0.9, fill: true, fillColor: '#32d3eb', fillOpacity: 0.5 } this.affectAreaOverlay = mapLayers.drawCircle(new CLatLng(affectCircle.lat, affectCircle.lng), affectCircle.radius, opts) }, // 移除影响区域 @@ -260,7 +257,7 @@ const options = { url: './static/images/map_images/alarm-well1.png', size: size, - anchor: anchor + anchor: [15, 30] } const cmapIcon = createIcon(options) const opts = { @@ -268,10 +265,10 @@ title: wellObj.wellCode, draggable: false } - this.wellOverlay = new CMarker(new CLatLng(wellObj.lat, wellObj.lng), opts) + this.wellOverlay = new CMarker(new CLatLng(wellObj.coordinateY, wellObj.coordinateX), opts) mapLayers.addOverlay(this.wellOverlay) mapLayers.setZoom(17) - mapLayers.setCenter(new CLatLng(wellObj.lat, wellObj.lng)) + mapLayers.setCenter(new CLatLng(wellObj.coordinateY, wellObj.coordinateX)) }, // 移除井 removeWell() { @@ -281,45 +278,54 @@ this.wellOverlay = null } }, - // 渲染问题影响管线 - renderAffectPipes() { - // TODO: 渲染管线 + // 渲染阀门 + renderValves() { + const { mapLayers, size, valves } = this + for (const valve of valves) { + const options = { + url: './static/images/map_images/valve1.png', + size: [20, 20], + anchor: [10, 10] + } + const cmapIcon = createIcon(options) + const opts = { + icon: cmapIcon, + title: valve.valveCode, + draggable: false + } + const valveOverlay = new CMarker(new CLatLng(valve.coordinateY, valve.coordinateX), opts) + mapLayers.addOverlay(valveOverlay) + this.valvesOverlays.push(valveOverlay) + mapLayers.setZoom(16) + } }, // 移除影响管线 - removeAffectPipes() { + removeValves() { const { mapLayers } = this - for (const overlay of this.affectLineOverlays) { + for (const overlay of this.valves) { mapLayers.removeOverlay(overlay) } - this.affectLineOverlays = [] + this.valves = [] }, // 渲染关阀影响区域 renderCloseArea() { - const { mapLayers, closeCircle } = this + const { mapLayers, closeAreas } = this + this.removeCloseArea() // 绘制影响区域 - const opts = { color: '#c45366', weight: 2, opacity: 0.9, fill: true, fillColor: '#009900', fillOpacity: 0.4 } - this.closeAreaOverlay = mapLayers.drawCircle(new CLatLng(closeCircle.lat, closeCircle.lng), closeCircle.radius, opts) + for (const valveArea of closeAreas) { + const opts = { color: '#e7944f', weight: 1, opacity: 0.9, fill: true, fillColor: '#e7944f', fillOpacity: 0.4 } + const polygon = mapLayers.drawPolygon(valveArea.position, opts) + this.closeAreaOverlays.push(polygon) + } }, // 移除关阀影响区域 removeCloseArea() { const { mapLayers } = this - if (this.closeAreaOverlay) { - mapLayers.removeOverlay(this.closeAreaOverlay) - this.closeAreaOverlay = null + if (this.closeAreaOverlays) { + mapLayers.removeOverlay(this.closeAreaOverlays) + this.closeAreaOverlays = [] } }, - // 渲染关阀影响管线 - renderClosePipes() { - // TODO: 渲染管线 - }, - // 移除关阀影响管线 - removeClosePipes() { - const { mapLayers } = this - for (const overlay of this.closeLineOverlays) { - mapLayers.removeOverlay(overlay) - } - this.closeLineOverlays = [] - }, // 清除所有overlay removeOverlays() { const { mapLayers } = this diff --git a/src/components/CMap/components/cmapSmart.vue b/src/components/CMap/components/cmapSmart.vue index 8146911..5e35283 100644 --- a/src/components/CMap/components/cmapSmart.vue +++ b/src/components/CMap/components/cmapSmart.vue @@ -21,13 +21,9 @@ wellObj: { // 井对象 type: Object, default: function() { - return { wellCode: '', id: '', lat: 39.9, lng: 116.4, radius: 10 } + return { wellCode: '', id: '', coordinateY: 39.9, coordinateX: 116.4, radius: '0' } } }, - valves: { // 阀门 - type: Array, - default: () => [] - }, zoom: { // 缩放层级 type: Number, default: 12 @@ -65,22 +61,26 @@ default: function() { return [0, -15] } + }, + valves: { // 阀门原始数据 + type: Array, + default: () => [] + }, + closeAreas: { // 关阀影响区域原始数据 + type: Array, + default: () => { + return [] + } } }, data() { return { - // wellObj: null, affectCicle: null, // 影响区域 - affectPipes: null, // 影响管线 - closeCircle: null, // 关阀影响区域 - closePipes: null, // 影响管线 mapLayers: null, // 地图图层 wellOverlay: null, // 井overlay - affectAreaOverlay: null, // 影响区域overlay - affectLineOverlays: [], // 影响管线overlay + affectAreaOverlay: [], // 影响区域overlay valvesOverlays: [], // 阀门overlay列表 - closeAreaOverlay: null, // 关阀影响区域overlay - closeLineOverlays: [] // 关阀影响区域overlay + closeAreaOverlays: [] // 关阀影响区域overlay } }, watch: { @@ -114,9 +114,20 @@ const { mapLayers } = this mapLayers.setMaxZoom(val) }, - alarmMarkers(val) { - console.log('alarmMarkers') - this.renderMarkers() + wellObj(val) { + if (val == null) { + this.removeOverlays() + } else { + this.renderAffectAP() + } + }, + valves(val) { + console.log('renderValves') + this.renderValves() + }, + closeAreas(val) { + console.log('renderValves') + this.renderCloseArea() } }, mounted() { @@ -197,8 +208,8 @@ this.$emit('ready', { mapLayers: this.mapLayers }) // this.renderMarkers() }, - renderAffectAP(wellObj) { - // this.wellObj = wellObj + // 渲染影响区域 + renderAffectAP() { const { mapLayers } = this if (!mapLayers) { return @@ -207,43 +218,29 @@ // 渲染井 if (this.wellObj != null) { this.affectCircle = { - lat: this.wellObj.lat, - lng: this.wellObj.lng, - radius: this.wellObj.radius - } - if (this.wellObj.affectPipes) { - this.affectPipes = this.wellObj.affectPipes + lat: this.wellObj.coordinateY, + lng: this.wellObj.coordinateX, + radius: parseFloat(this.wellObj.radius) } this.renderWell() - } - // 当影响区域不为空的时候显示影响区域 - if (this.affectCircle != null) { - this.renderAffectArea() - } - // 渲染管线 - if (this.affectPipes && this.affectPipes.length > 0) { - this.renderAffectPipes() + // 当影响区域不为空的时候显示影响区域 + if (this.affectCircle != null) { + this.renderAffectArea() + } } }, + // 移除影响区域 removeAffectAP() { - // 移除井 - // if (this.wellObj != null) { - // this.removeWell() - // } // 移除影响区域 if (this.affectArea != null) { this.removeAffectArea() } - // 移除管线 - if (this.affectPipes.length > 0) { - this.removeAffectPipes() - } }, // 渲染影响区域 renderAffectArea() { const { mapLayers, affectCircle } = this // 绘制影响区域 - const opts = { color: '#c45366', weight: 2, opacity: 0.9, fill: true, fillColor: '#009900', fillOpacity: 0.4 } + const opts = { color: '#boacfc', weight: 0, opacity: 0.9, fill: true, fillColor: '#32d3eb', fillOpacity: 0.5 } this.affectAreaOverlay = mapLayers.drawCircle(new CLatLng(affectCircle.lat, affectCircle.lng), affectCircle.radius, opts) }, // 移除影响区域 @@ -260,7 +257,7 @@ const options = { url: './static/images/map_images/alarm-well1.png', size: size, - anchor: anchor + anchor: [15, 30] } const cmapIcon = createIcon(options) const opts = { @@ -268,10 +265,10 @@ title: wellObj.wellCode, draggable: false } - this.wellOverlay = new CMarker(new CLatLng(wellObj.lat, wellObj.lng), opts) + this.wellOverlay = new CMarker(new CLatLng(wellObj.coordinateY, wellObj.coordinateX), opts) mapLayers.addOverlay(this.wellOverlay) mapLayers.setZoom(17) - mapLayers.setCenter(new CLatLng(wellObj.lat, wellObj.lng)) + mapLayers.setCenter(new CLatLng(wellObj.coordinateY, wellObj.coordinateX)) }, // 移除井 removeWell() { @@ -281,45 +278,54 @@ this.wellOverlay = null } }, - // 渲染问题影响管线 - renderAffectPipes() { - // TODO: 渲染管线 + // 渲染阀门 + renderValves() { + const { mapLayers, size, valves } = this + for (const valve of valves) { + const options = { + url: './static/images/map_images/valve1.png', + size: [20, 20], + anchor: [10, 10] + } + const cmapIcon = createIcon(options) + const opts = { + icon: cmapIcon, + title: valve.valveCode, + draggable: false + } + const valveOverlay = new CMarker(new CLatLng(valve.coordinateY, valve.coordinateX), opts) + mapLayers.addOverlay(valveOverlay) + this.valvesOverlays.push(valveOverlay) + mapLayers.setZoom(16) + } }, // 移除影响管线 - removeAffectPipes() { + removeValves() { const { mapLayers } = this - for (const overlay of this.affectLineOverlays) { + for (const overlay of this.valves) { mapLayers.removeOverlay(overlay) } - this.affectLineOverlays = [] + this.valves = [] }, // 渲染关阀影响区域 renderCloseArea() { - const { mapLayers, closeCircle } = this + const { mapLayers, closeAreas } = this + this.removeCloseArea() // 绘制影响区域 - const opts = { color: '#c45366', weight: 2, opacity: 0.9, fill: true, fillColor: '#009900', fillOpacity: 0.4 } - this.closeAreaOverlay = mapLayers.drawCircle(new CLatLng(closeCircle.lat, closeCircle.lng), closeCircle.radius, opts) + for (const valveArea of closeAreas) { + const opts = { color: '#e7944f', weight: 1, opacity: 0.9, fill: true, fillColor: '#e7944f', fillOpacity: 0.4 } + const polygon = mapLayers.drawPolygon(valveArea.position, opts) + this.closeAreaOverlays.push(polygon) + } }, // 移除关阀影响区域 removeCloseArea() { const { mapLayers } = this - if (this.closeAreaOverlay) { - mapLayers.removeOverlay(this.closeAreaOverlay) - this.closeAreaOverlay = null + if (this.closeAreaOverlays) { + mapLayers.removeOverlay(this.closeAreaOverlays) + this.closeAreaOverlays = [] } }, - // 渲染关阀影响管线 - renderClosePipes() { - // TODO: 渲染管线 - }, - // 移除关阀影响管线 - removeClosePipes() { - const { mapLayers } = this - for (const overlay of this.closeLineOverlays) { - mapLayers.removeOverlay(overlay) - } - this.closeLineOverlays = [] - }, // 清除所有overlay removeOverlays() { const { mapLayers } = this diff --git a/src/views/smartAnalysis/smartOverview.vue b/src/views/smartAnalysis/smartOverview.vue index 06d30b0..7a80cd9 100644 --- a/src/views/smartAnalysis/smartOverview.vue +++ b/src/views/smartAnalysis/smartOverview.vue @@ -1,93 +1,132 @@