| | |
| | | <el-button type="primary" size="mini" @click="draw('polygon')">绘制面</el-button> |
| | | <el-button type="primary" size="mini" @click="draw('polyline')">巡查路线</el-button> |
| | | <el-button type="primary" size="mini" @click="removeDrawLayer">清除</el-button> |
| | | <!-- <el-button type="primary" size="mini" @click="saveDraw">保存</el-button> --> |
| | | <el-button type="primary" size="mini" @click="draww('polyline')">绘制测试</el-button> |
| | | </div> |
| | | <!-- <div class="range-input" v-show="inputpopup"> |
| | | <div class="close" @click="closeRangeInput"></div> |
| | | <h3>请输入距离</h3> |
| | | <input type="text" v-model="range" /> |
| | | <button @click="changeRange" class="btn">确定</button> |
| | | </div>--> |
| | | |
| | | <div class="down-tree"> |
| | | <el-scrollbar> |
| | | <el-tree v-show="searchLazyFlag" :props="props" :load="loadNode" lazy node-key="id" |
| | |
| | | <div v-show="inputpopup"> |
| | | <div>距离:</div> |
| | | <input type="text" v-model="range" placeholder="请输入绘制线的范围" /> |
| | | <!-- <button @click="changeRange" class="btn">确定</button> --> |
| | | </div> |
| | | <div> |
| | | <button @click="saveDrawInfo">保存</button> |
| | |
| | | inputpopup: false, |
| | | changeBtn: false, |
| | | drawName: '', |
| | | drawInfo: [], |
| | | drawType: 1, |
| | | // saveFlag: true, |
| | | searchExtensivelyValue: '', |
| | | searchExtensivelyValBoxShow: false, |
| | | searchExtensivelyArray: [], |
| | |
| | | defaultExpandedKeys: [], |
| | | searchLazyFlag: true, |
| | | searchTreeData: [], |
| | | drawPlotData:{}, |
| | | } |
| | | }, |
| | | |
| | |
| | | |
| | | drawDialogBeforeClose () { |
| | | this.drawName = '' |
| | | this.removeDrawLayer() |
| | | if(drawPlotLayers!=null){ |
| | | drawPlotLayers.clear() |
| | | } |
| | | this.$EventBus.$emit('mapRemoveLayer', { |
| | | layerName: 'monitoringLayers', |
| | | type: 'VectorLayer' |
| | | }) |
| | | this.drawDialogVisible = false |
| | | }, |
| | | |
| | |
| | | } |
| | | }, |
| | | |
| | | // 封装方法绘制线面 type:polygon/polyline |
| | | // draww (type) { |
| | | // if (graphicLayer == null) graphicLayer = new EntityDraw() |
| | | // graphicLayer.activate(type, (lastEventData) => { |
| | | // }) |
| | | // }, |
| | | |
| | | draw (type) { |
| | | let flag = false |
| | | if (graphicLayer == null) graphicLayer = new EntityDraw() |
| | | |
| | | // this.saveFlag = true |
| | | if (type == 'polyline') { |
| | | this.inputpopup = true |
| | | this.drawType = 1 |
| | | } else { |
| | | this.inputpopup = false |
| | | this.drawType = 2 |
| | | } |
| | | const that = this |
| | | |
| | | |
| | | graphicLayer.activate(type, (lastEventData) => { |
| | | flag = true |
| | | this.drawInfo = lastEventData |
| | | console.log(1111, JSON.stringify(lastEventData)) |
| | | this.getRegionList(type, JSON.stringify(lastEventData)) |
| | | this.drawDialogVisible = true |
| | | |
| | | document.oncontextmenu = function () { |
| | | if (flag) { |
| | | this.drawDialogVisible = true |
| | | flag = false |
| | | } |
| | | return false |
| | | } |
| | | }) |
| | | |
| | | }, |
| | | |
| | | draww (type) { |
| | | if (type == 'polyline') { |
| | | this.inputpopup = true |
| | | this.drawType = 1 |
| | |
| | | if (overlay) { |
| | | drawPlotLayers.addOverlay(overlay) |
| | | plot.edit(overlay, (e) => { |
| | | console.log('overlay', overlay) |
| | | this.drawDialogVisible = true |
| | | this.range = 100 |
| | | this.drawPlotData = overlay |
| | | document.oncontextmenu = function () { |
| | | return false |
| | | } |
| | | this.getRegionList(type, overlay) |
| | | }) |
| | | } |
| | | } |
| | |
| | | removeDrawLayer () { |
| | | this.inputpopup = false |
| | | this.monitoringList = this.monitoringSaveList |
| | | graphicLayer.clearLayer() |
| | | // this.saveFlag = true |
| | | this.drawInfo = [] |
| | | if(drawPlotLayers!=null){ |
| | | drawPlotLayers.clear() |
| | | } |
| | | this.drawPlotData = [] |
| | | this.$EventBus.$emit('mapRemoveLayer', { |
| | | layerName: 'monitoringLayers', |
| | | type: 'VectorLayer' |
| | |
| | | // 修改范围 |
| | | setRegion (range) { |
| | | graphicLayer.addPolyLineGon(range, (lastEventData) => { |
| | | this.drawInfo = lastEventData |
| | | this.getRegionList('polyline', JSON.stringify(lastEventData)) |
| | | // this.getRegionList('polyline', JSON.stringify(lastEventData)) |
| | | }) |
| | | }, |
| | | |
| | |
| | | getRegionList (type, data) { |
| | | let positionStr = '' |
| | | if (type == 'polyline') { |
| | | JSON.parse(data).data.forEach(item => { |
| | | positionStr = positionStr + item[0] + ',' + item[1] + ';' |
| | | data._positions.forEach(item=>{ |
| | | positionStr = positionStr + item._lng + ',' + item._lat + ';' |
| | | }) |
| | | console.log('positionStr',positionStr); |
| | | let coords = global.DC.GeoTools.polylineBuffer(positionStr, 100) |
| | | let polygon = new global.DC.Polygon(coords) |
| | | let position = '' |
| | | polygon._positions.forEach(item => { |
| | | position += item._lng + ',' + item._lat + ';' |
| | | }) |
| | | position += polygon._positions[0]._lng +',' + polygon._positions[0]._lat+ ';' |
| | | positionStr = position |
| | | } else { |
| | | JSON.parse(data).data.forEach(item => { |
| | | positionStr = positionStr + item.lng + ',' + item.lat + ';' |
| | | data._positions.forEach(item=>{ |
| | | positionStr = positionStr + item._lng + ',' + item._lat + ';' |
| | | }) |
| | | positionStr = positionStr + JSON.parse(data).data[0].lng + ',' + JSON.parse(data).data[0].lat + ';' |
| | | positionStr = positionStr + data._positions[0]._lng + ',' + data._positions[0]._lat + ';' |
| | | } |
| | | |
| | | getRegionList({ |
| | | page: 1, |
| | | count: 20, |
| | |
| | | * @return {*} |
| | | */ |
| | | initMonitoringIcon () { |
| | | this.monitoringList.forEach((item, index) => { |
| | | this.monitoringList.forEach(item => { |
| | | this.$EventBus.$emit('layerPointAdd', { |
| | | layerName: 'monitoringLayers', |
| | | type: "billboard", |
| | |
| | | }) |
| | | }, |
| | | |
| | | // saveDraw () { |
| | | // if (this.drawInfo.length != 0) { |
| | | // this.drawDialogVisible = true |
| | | // this.saveFlag = false |
| | | // } else { |
| | | // this.$message({ |
| | | // message: '请先绘制线或者面', |
| | | // type: 'warning' |
| | | // }) |
| | | // } |
| | | // }, |
| | | |
| | | // 保存绘制的线面 |
| | | saveDrawInfo () { |
| | | if (this.drawName == '') { |
| | |
| | | }) |
| | | } else { |
| | | let drawPositionStr = '' |
| | | let drawPositionLineStr = '' |
| | | let extent = 0 |
| | | let width = 0 |
| | | |
| | | if (this.drawType == 1) { |
| | | // 获取线坐标 |
| | | this.drawPlotData._positions.forEach(item => { |
| | | drawPositionStr += item._lng + ' ' + item._lat+ ',' |
| | | }) |
| | | drawPositionStr = drawPositionStr.slice(0, drawPositionStr.length - 1) |
| | | // 求线长度 |
| | | let linePosition = [] |
| | | this.drawInfo.lineData.forEach(item => { |
| | | linePosition.push([item.lng, item.lat]) |
| | | this.drawPlotData._positions.forEach(item => { |
| | | linePosition.push([item._lng, item._lat]) |
| | | }) |
| | | let line = this.$turf.lineString(linePosition) |
| | | let length = this.$turf.length(line, { units: 'kilometers' }) |
| | | extent = length.toFixed(3) |
| | | this.drawInfo.data.forEach(item => { |
| | | drawPositionStr += item[0] + ' ' + item[1] + ',' |
| | | }) |
| | | this.drawInfo.lineData.forEach(item => { |
| | | drawPositionLineStr += item.lng + ' ' + item.lat + ',' |
| | | }) |
| | | drawPositionStr = drawPositionStr.slice(0, drawPositionStr.length - 1) |
| | | drawPositionLineStr = drawPositionLineStr.slice(0, drawPositionLineStr.length - 1) |
| | | } else { |
| | | this.drawInfo.data.forEach(item => { |
| | | // 获取面坐标 |
| | | this.drawPlotData._positions.forEach(item => { |
| | | drawPositionStr += item.lng + ' ' + item.lat + ',' |
| | | }) |
| | | drawPositionStr += this.drawInfo.data[0].lng + ' ' + this.drawInfo.data[0].lat |
| | | drawPositionStr += this.drawPlotData._positions[0]._lng + ' ' + this.drawPlotData._positions[0]._lat |
| | | // 求面面积 |
| | | let polygonPosition = [] |
| | | this.drawPlotData._positions.forEach(item => { |
| | | polygonPosition.push([item._lng, item._lat]) |
| | | }) |
| | | polygonPosition.push([this.drawPlotData._positions[0]._lng,this.drawPlotData._positions[0]._lat]) |
| | | let polygon = this.$turf.polygon([polygonPosition]); |
| | | let area = this.$turf.area(polygon); |
| | | extent = area.toFixed(3) |
| | | } |
| | | |
| | | this.insertRegionSaveList(this.drawType, drawPositionStr, this.drawName, drawPositionLineStr, extent) |
| | | console.log({type:this.drawType, position:drawPositionStr, name:this.drawName, extent: extent,width:this.range},5555,this.drawPlotData._positions); |
| | | this.insertRegionSaveList({type:this.drawType, positions:drawPositionStr, name:this.drawName, extent: extent,width:this.range}) |
| | | this.drawDialogVisible = false |
| | | this.drawName = '' |
| | | this.removeDrawLayer() |
| | | if(drawPlotLayers!=null) { |
| | | drawPlotLayers.clear() |
| | | } |
| | | this.$EventBus.$emit('mapRemoveLayer', { |
| | | layerName: 'monitoringLayers', |
| | | type: 'VectorLayer' |
| | | }) |
| | | } |
| | | }, |
| | | |
| | | // 取消绘制线面 |
| | | cancelSaveDrawInfo () { |
| | | this.removeDrawLayer() |
| | | this.drawDialogVisible = false |
| | | this.drawDialogBeforeClose () |
| | | }, |
| | | |
| | | insertRegionSaveList (type, positions, name, patrol, extent) { |
| | | insertRegionSaveList(type, positions, name, patrol, extent).then(res => { |
| | | // type线面类型, positions坐标, name名称, width线宽度, extent线长度或面面积 |
| | | insertRegionSaveList (parmas) { |
| | | insertRegionSaveList(parmas).then(res => { |
| | | if (res.data.success) { |
| | | this.$message({ |
| | | message: '保存成功', |