|
|
|
@ -2,9 +2,10 @@ import { Component, OnInit, Renderer2, ElementRef } from '@angular/core';
|
|
|
|
|
import { HttpClient } from '@angular/common/http' |
|
|
|
|
import { Router } from '@angular/router'; |
|
|
|
|
import { EchartsDataService } from '../echarts-data.service'; |
|
|
|
|
import { MapFactory } from '@src/modules/map/declare/factory'; |
|
|
|
|
import { IMap } from '@src/modules/map/declare/map'; |
|
|
|
|
declare var echarts: any; |
|
|
|
|
declare var AMap: any; |
|
|
|
|
declare var AMapUI: any; |
|
|
|
|
|
|
|
|
|
@Component({ |
|
|
|
|
selector: 'app-home', |
|
|
|
|
templateUrl: './home.component.html', |
|
|
|
@ -14,24 +15,10 @@ export class HomeComponent implements OnInit {
|
|
|
|
|
|
|
|
|
|
constructor(private http:HttpClient, private render2: Renderer2,public element: ElementRef,private router: Router,public emitService: EchartsDataService) { } |
|
|
|
|
|
|
|
|
|
map:any; //地图
|
|
|
|
|
map:IMap; //地图
|
|
|
|
|
yuandata |
|
|
|
|
ngOnInit() { |
|
|
|
|
this.level=sessionStorage.getItem("level") |
|
|
|
|
this.getechartsdata() |
|
|
|
|
/* this.emitService.eventEmit.subscribe((value: any) => { |
|
|
|
|
if (value == 'echarts') { |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.updateEcharts() |
|
|
|
|
}, 500); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
window.addEventListener('resize', () => { |
|
|
|
|
setTimeout(() => { |
|
|
|
|
this.updateEcharts() |
|
|
|
|
}, 0); |
|
|
|
|
}) */ |
|
|
|
|
|
|
|
|
|
this.getechartsdata() |
|
|
|
|
window.setTimeout(()=>{ |
|
|
|
|
/* this.unitType() |
|
|
|
|
this.unitData() |
|
|
|
@ -102,231 +89,37 @@ export class HomeComponent implements OnInit {
|
|
|
|
|
} |
|
|
|
|
//初始化地图
|
|
|
|
|
adcode:any //行政编码
|
|
|
|
|
level//组织级别
|
|
|
|
|
level = sessionStorage.getItem("level")//组织级别
|
|
|
|
|
orid |
|
|
|
|
mapInit () { |
|
|
|
|
//创建地图
|
|
|
|
|
this.map = new AMap.Map('chartMap', { |
|
|
|
|
cursor: 'default', |
|
|
|
|
zooms:[8,16], |
|
|
|
|
mapStyle:"amap://styles/grey",
|
|
|
|
|
// bubble: true
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
let colors = [ |
|
|
|
|
"#3366cc", "#dc3912", "#ff9900", "#109618", "#990099", "#0099c6", "#dd4477", "#66aa00", |
|
|
|
|
"#b82e2e", "#316395", "#994499", "#22aa99", "#aaaa11", "#6633cc", "#e67300", "#8b0707", |
|
|
|
|
"#651067", "#329262", "#5574a6", "#3b3eac" |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
AMapUI.loadUI(['geo/DistrictExplorer'], (DistrictExplorer)=> { |
|
|
|
|
|
|
|
|
|
//创建一个实例
|
|
|
|
|
let districtExplorer = new DistrictExplorer({ |
|
|
|
|
map: this.map, |
|
|
|
|
eventSupport: true, //打开事件支持
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// let adcode = this.adcode; //行政编码
|
|
|
|
|
let adcode |
|
|
|
|
if(sessionStorage.getItem("realName") == "上海总队"){ |
|
|
|
|
adcode = 310000 |
|
|
|
|
}else{ |
|
|
|
|
adcode = 310000 |
|
|
|
|
//封装Gaode
|
|
|
|
|
getEchartsData (data) { |
|
|
|
|
return new Promise((resolve, reject)=>{ |
|
|
|
|
let paramsdata:any ={ |
|
|
|
|
name:data.properties.name, |
|
|
|
|
level:Number(this.level)+1 |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
districtExplorer.loadAreaNode(adcode, (error, areaNode)=> { |
|
|
|
|
|
|
|
|
|
//更新地图视野
|
|
|
|
|
this.map.setBounds(areaNode.getBounds(), null, null, true); |
|
|
|
|
|
|
|
|
|
//设置定位节点,支持鼠标位置识别
|
|
|
|
|
//注意节点的顺序,前面的高优先级
|
|
|
|
|
districtExplorer.setAreaNodesForLocating(areaNode); |
|
|
|
|
|
|
|
|
|
//清除已有的绘制内容
|
|
|
|
|
districtExplorer.clearFeaturePolygons(); |
|
|
|
|
|
|
|
|
|
//绘制子区域
|
|
|
|
|
districtExplorer.renderSubFeatures(areaNode, (feature, i) =>{ |
|
|
|
|
// console.log(123,feature,i)
|
|
|
|
|
|
|
|
|
|
let fillColor = colors[i % colors.length]; |
|
|
|
|
let strokeColor = colors[colors.length - 1 - i % colors.length]; |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
cursor: 'default', |
|
|
|
|
bubble: true, |
|
|
|
|
strokeColor: strokeColor, //线颜色
|
|
|
|
|
strokeOpacity: 1, //线透明度
|
|
|
|
|
strokeWeight: 1, //线宽
|
|
|
|
|
fillColor: fillColor, //填充色
|
|
|
|
|
fillOpacity: 0.5, //填充透明度
|
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
//绘制父区域
|
|
|
|
|
districtExplorer.renderParentFeature(areaNode, { |
|
|
|
|
cursor: 'default', |
|
|
|
|
bubble: true, |
|
|
|
|
strokeColor: 'black', //线颜色
|
|
|
|
|
strokeOpacity: 1, //线透明度
|
|
|
|
|
strokeWeight: 1, //线宽
|
|
|
|
|
fillColor: null, //填充色
|
|
|
|
|
fillOpacity: 0.5, //填充透明度
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// 更新地图视野以适合区划面
|
|
|
|
|
this.map.setFitView(districtExplorer.getAllFeaturePolygons()); |
|
|
|
|
}); |
|
|
|
|
if(this.level=="0"||this.level=="1"||this.level=="2"){ |
|
|
|
|
//区域内点击
|
|
|
|
|
districtExplorer.on('featureClick', (e, feature) =>{ |
|
|
|
|
//console.log(feature)
|
|
|
|
|
let paramsdata:any ={ |
|
|
|
|
name:feature.properties.name, |
|
|
|
|
level:Number(this.level)+1 |
|
|
|
|
} |
|
|
|
|
this.http.get("/api/Organizations/GetIdByName",{params:paramsdata}).subscribe((data:any)=>{ |
|
|
|
|
console.log(data) |
|
|
|
|
this.orid=data[0] |
|
|
|
|
this.getechartsdata() |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
let props = feature.properties; |
|
|
|
|
adcode = props.adcode |
|
|
|
|
let fillColor2 |
|
|
|
|
if(props.level == 'city'){ |
|
|
|
|
fillColor2 = null |
|
|
|
|
}else{ |
|
|
|
|
fillColor2 = '#d0daee' |
|
|
|
|
} |
|
|
|
|
districtExplorer.loadAreaNode(adcode, (error, areaNode)=> { |
|
|
|
|
//更新地图视野
|
|
|
|
|
// this.map.setBounds(areaNode.getBounds(), null, null, true);
|
|
|
|
|
|
|
|
|
|
//设置定位节点,支持鼠标位置识别
|
|
|
|
|
//注意节点的顺序,前面的高优先级
|
|
|
|
|
districtExplorer.setAreaNodesForLocating(areaNode); |
|
|
|
|
|
|
|
|
|
//清除已有的绘制内容
|
|
|
|
|
districtExplorer.clearFeaturePolygons(); |
|
|
|
|
|
|
|
|
|
//绘制子区域
|
|
|
|
|
districtExplorer.renderSubFeatures(areaNode, (feature, i) =>{ |
|
|
|
|
let fillColor = colors[i % colors.length]; |
|
|
|
|
// console.log(111,fillColor)
|
|
|
|
|
let strokeColor = colors[colors.length - 1 - i % colors.length]; |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
cursor: 'default', |
|
|
|
|
bubble: true, |
|
|
|
|
strokeColor: strokeColor, //线颜色
|
|
|
|
|
strokeOpacity: 1, //线透明度
|
|
|
|
|
strokeWeight: 1, //线宽
|
|
|
|
|
fillColor: fillColor, //填充色
|
|
|
|
|
fillOpacity: 0.5, //填充透明度
|
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
//绘制父区域
|
|
|
|
|
districtExplorer.renderParentFeature(areaNode, { |
|
|
|
|
cursor: 'default', |
|
|
|
|
bubble: true, |
|
|
|
|
strokeColor: 'black', //线颜色
|
|
|
|
|
strokeOpacity: 1, //线透明度
|
|
|
|
|
strokeWeight: 1, //线宽
|
|
|
|
|
fillColor: fillColor2, //填充色
|
|
|
|
|
fillOpacity: 0.5, //填充透明度
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// 更新地图视野以适合区划面
|
|
|
|
|
this.map.setFitView(districtExplorer.getAllFeaturePolygons()); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
//this.planState.setOption(this.planStateOptionsZhong);
|
|
|
|
|
//this.chartDwsjcj.setOption(this.chartDwsjcjOptionsZhong);
|
|
|
|
|
//this.chartZdgzqy.setOption(this.chartZdgzqyOptionsZhong);
|
|
|
|
|
/* this.planNum = ["0","0","3","1","6","5"] |
|
|
|
|
this.keyUnitNum = 666 */ |
|
|
|
|
//this.dataGetNum = 456
|
|
|
|
|
|
|
|
|
|
/* this.threePlanNum = "867" |
|
|
|
|
this.twoPlanNum = "485" |
|
|
|
|
this.cardPlanNum = "756" |
|
|
|
|
this.otherPlanNum = "658" */ |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
districtExplorer.on('outsideClick', (e) => { |
|
|
|
|
this.orid='' |
|
|
|
|
this.http.get("/api/Organizations/GetIdByName",{params:paramsdata}).subscribe((data:any)=>{ |
|
|
|
|
this.orid=data[0] |
|
|
|
|
this.getechartsdata() |
|
|
|
|
// console.log('区域外点击');
|
|
|
|
|
let adcode |
|
|
|
|
if(sessionStorage.getItem("realName") == "上海总队"){ |
|
|
|
|
adcode = 310000 |
|
|
|
|
}else{ |
|
|
|
|
adcode = 310000 |
|
|
|
|
} |
|
|
|
|
districtExplorer.loadAreaNode(adcode, (error, areaNode)=> { |
|
|
|
|
//更新地图视野
|
|
|
|
|
// this.map.setBounds(areaNode.getBounds(), null, null, true);
|
|
|
|
|
|
|
|
|
|
//设置定位节点,支持鼠标位置识别
|
|
|
|
|
//注意节点的顺序,前面的高优先级
|
|
|
|
|
districtExplorer.setAreaNodesForLocating(areaNode); |
|
|
|
|
|
|
|
|
|
//清除已有的绘制内容
|
|
|
|
|
districtExplorer.clearFeaturePolygons(); |
|
|
|
|
|
|
|
|
|
//绘制子区域
|
|
|
|
|
districtExplorer.renderSubFeatures(areaNode, (feature, i) =>{ |
|
|
|
|
let fillColor = colors[i % colors.length]; |
|
|
|
|
// console.log(111,fillColor)
|
|
|
|
|
let strokeColor = colors[colors.length - 1 - i % colors.length]; |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
cursor: 'default', |
|
|
|
|
bubble: true, |
|
|
|
|
strokeColor: strokeColor, //线颜色
|
|
|
|
|
strokeOpacity: 1, //线透明度
|
|
|
|
|
strokeWeight: 1, //线宽
|
|
|
|
|
fillColor: fillColor, //填充色
|
|
|
|
|
fillOpacity: 0.5, //填充透明度
|
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
//绘制父区域
|
|
|
|
|
districtExplorer.renderParentFeature(areaNode, { |
|
|
|
|
cursor: 'default', |
|
|
|
|
bubble: true, |
|
|
|
|
strokeColor: 'black', //线颜色
|
|
|
|
|
strokeOpacity: 1, //线透明度
|
|
|
|
|
strokeWeight: 1, //线宽
|
|
|
|
|
fillColor: null, //填充色
|
|
|
|
|
fillOpacity: 0.5, //填充透明度
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// 更新地图视野以适合区划面
|
|
|
|
|
this.map.setFitView(districtExplorer.getAllFeaturePolygons()); |
|
|
|
|
}); |
|
|
|
|
/* this.planState.setOption(this.planStateOptionsZhi); |
|
|
|
|
this.chartDwsjcj.setOption(this.chartDwsjcjOptionsZhi); |
|
|
|
|
this.chartZdgzqy.setOption(this.chartZdgzqyOptionsZhi); */ |
|
|
|
|
/* this.planNum = ["0","2","2","6","7","8"] |
|
|
|
|
this.keyUnitNum = 8036 |
|
|
|
|
this.dataGetNum = 6578 */ |
|
|
|
|
|
|
|
|
|
/* this.threePlanNum = "4374" |
|
|
|
|
this.twoPlanNum = "9693" |
|
|
|
|
this.cardPlanNum = "6403" |
|
|
|
|
this.otherPlanNum = "2208" */ |
|
|
|
|
resolve('success') |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
setEchartsData () { |
|
|
|
|
this.orid='' |
|
|
|
|
this.getechartsdata() |
|
|
|
|
} |
|
|
|
|
//封装Gaode
|
|
|
|
|
|
|
|
|
|
mapInit () { |
|
|
|
|
//创建地图
|
|
|
|
|
this.map = MapFactory.MapInstance('chartMap', { |
|
|
|
|
cursor: 'default', |
|
|
|
|
zooms:[8,16], |
|
|
|
|
mapStyle:"amap://styles/grey",
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.map.setAdministrativeAreaStyle(this,this.getEchartsData,this.setEchartsData) |
|
|
|
|
} |
|
|
|
|
planNum = [] |
|
|
|
|
keyUnitNum |
|
|
|
|