diff --git a/src/views/modules/communityParty/regionalParty/finishList.vue b/src/views/modules/communityParty/regionalParty/finishList.vue index e9965972..e6eaaad2 100644 --- a/src/views/modules/communityParty/regionalParty/finishList.vue +++ b/src/views/modules/communityParty/regionalParty/finishList.vue @@ -258,9 +258,13 @@ export default { } this.monthlist = [] for (let i = 1; i < 13; i++) { + let m = i + if (m < 10) { + m = '0' + m + } let obj = { label: i + '月', - value: i + '', + value: m, } this.monthlist.push(obj) diff --git a/src/views/modules/visual/basicinfo/basicInfoMain.vue b/src/views/modules/visual/basicinfo/basicInfoMain.vue index 5aa402e8..adae7b0e 100644 --- a/src/views/modules/visual/basicinfo/basicInfoMain.vue +++ b/src/views/modules/visual/basicinfo/basicInfoMain.vue @@ -121,6 +121,8 @@ let loading;//加载动画 let map; let mapView; let gaodeMapLayer;//背景地图图层 +let parentLayer;//上级组织图层 +let parentSource;//上级组织多边形 let polygonLayer;//变电站标注图层 let iconLayer; // icon标注图层 let iconSource; // icon @@ -167,8 +169,25 @@ var createTextStyle = function (feature) { }); }; -//变电站标注样式 +//上级组织标注样式 +var parentStyleFunction = (function () { + return function (feature) { + return new Style({ + // fill: new Fill({ + // color: [255, 255, 255, 0.3] + // }), + stroke: new Stroke({ + color: [0, 103, 182, 1], + width: 2 + }), + + // text: createTextStyle(feature) + });; + }; +})() + +//变电站标注样式 var polygonStyleFunction = (function () { return function (feature) { return new Style({ @@ -216,6 +235,7 @@ const vueGis = { selUserId: '', center: [], zoom: null, + parentPolygon: [], } @@ -227,7 +247,8 @@ const vueGis = { //初始化地图 this.initMap() - + this.addParentLayer() + this.loadParentPolygon() //添加标注图层 this.addPolygonLayer() @@ -365,16 +386,17 @@ const vueGis = { //加载组织数据 await this.loadOrgData() + this.loadParentPolygon() //加载当前园区的标注 await this.loadPolygon(this.subAgencyArray) - //重置地图中心点 - if (isRefreshView) { - this.setMapLocation() - mapView.setCenter(this.centerPoint); - mapView.setZoom(this.zoom); - } + // //重置地图中心点 + // if (isRefreshView) { + // this.setMapLocation() + // mapView.setCenter(this.centerPoint); + // mapView.setZoom(this.zoom); + // } await this.loadList() @@ -431,7 +453,8 @@ const vueGis = { this.orgData = data this.orgId = this.orgData.id this.orgLevel = this.orgData.level - + this.parentPolygon = [] + this.parentPolygon.push(data) if (data.children && data.children.length > 0) { this.subAgencyArray = data.children } else { @@ -444,6 +467,63 @@ const vueGis = { }, + //加载父级组织多边形 + loadParentPolygon () { + parentSource.clear()//清空变电站标注 + + let featureData = []//标注数据 + if (this.parentPolygon && this.parentPolygon.length > 0) {//判断是否存在下级标注 + let oneData = {} + + this.parentPolygon.forEach(agencyItem => { + + if (agencyItem.coordinates && agencyItem.coordinates !== '') {//如果有坐标 + oneData = { + type: 'Feature', + id: agencyItem.id, + properties: { + id: agencyItem.id, + level: agencyItem.level, + name: agencyItem.name + }, + geometry: { + type: 'Polygon', + coordinates: [], + }, + } + let coorArray = agencyItem.coordinates.split(',')//坐标数组 + + let itemArray = []//单个点位的[lon,lat],数组 + let polygonArray = []//整个多边形的[[lon,lat],[lon,lat],[lon,lat]]数组 + + coorArray.forEach((item, index) => { + itemArray.push(item) + if (index % 2 == 0) {//偶 + + } else {//奇 + polygonArray.push(itemArray) + itemArray = [] + } + + }); + oneData.geometry.coordinates.push(polygonArray) + featureData.push(oneData) + } + }); + } + + if (featureData && featureData.length > 0) { + var geojsonObject = { + 'type': 'FeatureCollection', + 'features': featureData + }; + let feature = (new GeoJSON()).readFeatures(geojsonObject) + parentSource.addFeatures(feature) + + } + + }, + //加载当前园区的标注 loadPolygon (subAgencyArray) { polygonSource.clear()//清空多边形标注 @@ -626,6 +706,23 @@ const vueGis = { }); map.removeInteraction(dblClickInteraction); + }, + //添加变电站标注图层 + addParentLayer () { + parentSource = new VectorSource({ + //features: (new GeoJSON()).readFeatures(geojsonObject) + }); + + parentLayer = new VectorLayer({ + source: parentSource, + style: parentStyleFunction, + zIndex: 50 + }); + + + map.addLayer(parentLayer) + + }, //添加变电站标注图层 diff --git a/src/views/modules/workSys/mapConfig.vue b/src/views/modules/workSys/mapConfig.vue index b4d1fdda..6569f3e5 100644 --- a/src/views/modules/workSys/mapConfig.vue +++ b/src/views/modules/workSys/mapConfig.vue @@ -83,6 +83,8 @@ let projection = new Projection({ let map; let mapView; let gaodeMapLayer;//背景地图图层 +let parentLayer;//上级组织图层 +let parentSource;//上级组织多边形 let polygonLayer;//变电站标注图层 let polygonSource;//变电站标注多边形 @@ -106,7 +108,22 @@ var createTextStyle = function (feature) { overflow: true, }); }; -//变电站标注样式 +//上级组织标注样式 +var parentStyleFunction = (function () { + return function (feature) { + return new Style({ + // fill: new Fill({ + // color: [255, 255, 255, 0.3] + // }), + stroke: new Stroke({ + color: [0, 103, 182, 1], + width: 2 + }), + + // text: createTextStyle(feature) + });; + }; +})() var polygonStyleFunction = (function () { return function (feature) { @@ -153,6 +170,7 @@ const vueGis = { runAgency: [], center: [], zoom: null, + parentPolygon: [], } }, @@ -164,6 +182,10 @@ const vueGis = { //初始化地图 this.initMap() + //上级组织多边形图层 + this.addParentLayer() + this.loadParentPolygon() + //添加标注图层 this.addPolygonLayer() @@ -199,16 +221,16 @@ const vueGis = { async refreshMap (isRefreshView) { //加载组织数据 await this.loadOrgData() - + this.loadParentPolygon() //加载当前园区的标注 this.loadPolygon(this.subAgencyArray) //重置地图中心点 - if (isRefreshView) { - this.setMapLocation() - mapView.setCenter(this.centerPoint); - mapView.setZoom(this.zoom); - } + // if (isRefreshView) { + // this.setMapLocation() + // mapView.setCenter(this.centerPoint); + // mapView.setZoom(this.zoom); + // } }, //返回上一级组织 @@ -250,6 +272,8 @@ const vueGis = { this.subAgencyArray.push(data) // this.selAgencyId = data.id } else { + this.parentPolygon = [] + this.parentPolygon.push(data) if (data.children && data.children.length > 0) { this.subAgencyArray = data.children @@ -266,6 +290,62 @@ const vueGis = { }, + //加载父级组织多边形 + loadParentPolygon () { + parentSource.clear()//清空变电站标注 + + let featureData = []//标注数据 + if (this.parentPolygon && this.parentPolygon.length > 0) {//判断是否存在下级标注 + let oneData = {} + + this.parentPolygon.forEach(agencyItem => { + + if (agencyItem.coordinates && agencyItem.coordinates !== '') {//如果有坐标 + oneData = { + type: 'Feature', + id: agencyItem.id, + properties: { + id: agencyItem.id, + level: agencyItem.level, + name: agencyItem.name + }, + geometry: { + type: 'Polygon', + coordinates: [], + }, + } + let coorArray = agencyItem.coordinates.split(',')//坐标数组 + + let itemArray = []//单个点位的[lon,lat],数组 + let polygonArray = []//整个多边形的[[lon,lat],[lon,lat],[lon,lat]]数组 + + coorArray.forEach((item, index) => { + itemArray.push(item) + if (index % 2 == 0) {//偶 + + } else {//奇 + polygonArray.push(itemArray) + itemArray = [] + } + + }); + oneData.geometry.coordinates.push(polygonArray) + featureData.push(oneData) + } + }); + } + + if (featureData && featureData.length > 0) { + var geojsonObject = { + 'type': 'FeatureCollection', + 'features': featureData + }; + let feature = (new GeoJSON()).readFeatures(geojsonObject) + parentSource.addFeatures(feature) + + } + + }, //加载当前园区的标注 loadPolygon (subAgencyArray) { polygonSource.clear()//清空变电站标注 @@ -348,6 +428,7 @@ const vueGis = { } if (this.method != 'mAddPolygon' && this.level != 'neighborHood') { + this.selAgencyId = '' //下钻到下一级 this.subAgencyArray.forEach(item => { @@ -366,6 +447,7 @@ const vueGis = { console.log('center', map.getView().getCenter()) console.log('zoom', map.getView().getZoom()) + this.runAgency.push(this.selPolygon) this.selAgencyIndex = 0 this.refreshMap(true) @@ -373,7 +455,6 @@ const vueGis = { } }, - //高亮某个标注 highlightPolygon () { @@ -467,6 +548,23 @@ const vueGis = { }, + //添加变电站标注图层 + addParentLayer () { + parentSource = new VectorSource({ + //features: (new GeoJSON()).readFeatures(geojsonObject) + }); + + parentLayer = new VectorLayer({ + source: parentSource, + style: parentStyleFunction, + zIndex: 50 + }); + + + map.addLayer(parentLayer) + + + }, //添加变电站标注图层 addPolygonLayer () { polygonSource = new VectorSource({