import styles from './modalMap.scss';// 样式
import React, { Component } from 'react';
import BBDMapChinaDataRange from 'components/common/echarts/BBDMapChinaDataRange';
import {cityDistribute} from 'services/screenDisplay/monitorRisking.js';
import {isNotEmpty} from 'utils/util.js';
//地图上高亮label的图片
const iconJG = 'image://data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADMAAAAzCAYAAAA6oTAqAAALFklEQVRoQ+2aD2wb1R3Hf+/P2Wc7jt2kSUaarqWUbbgta/GENsTAElRqGYhtUrZVwIBROsaE1AISAoHaQjtQJ61DDG3rNk0b3R+IBhMdjI0/dRkIscl0rBAyyLqEpmn+NH8dn893996b3vnOOTu2YyetNCEiRfbZZ9/7vN/39/eM4CP0hz5CLPAxzP+rNc+oZQTUZ2nn4uJMbc6ZgEHuanYDoJ3OyrocsE7PSruc550AYjcA7AQogCDP84XCLQamAAEASC6+sxPI4GZ6GSZwKQi4SAj0KQyiTTDUgIQYEwwNIAY9QsAbPINfar8n1ysBuwGEC7YYqAXBeOQkP48GfgAR0krvFgDbkEDNwMHeZyQf3X+Bio+5fF+8BRba0/2ccWg0CWKxUPXC2NaQcopJSyQS6NQtr35XYPwAEtAMAtmLL0DIk+3j/OtzIR07MPGGmBE73nvITI0CiM78mdIB6/KnmmG81kgC4PZdEA2fT38NCDbnF+qAOADu4m0Qz2s2qH1cDI4EGNyAHScOrf1ZPJXiux3p1QNUE0wpyLmPqct9zdYhELDGXdS8sirIbtZKtpkLUkQgj7kl9rc+t/aeZColEo4tawWqBca+ZhcAlrI6+YVkBK+jSeCwdqGyKvalEhlKWRrwwNChVftGu7v5EQAug0MtQPPCOFZBUlrZ1UDW7yJPAqBrFysrV2pz/QukhTjPiGuHXzzvr2u6u1mtkqsKI0Gks18OgFtiMbzk7p5tSCGPuT5QNVrVKKtZmTmBwwkiwGFEnEAb+j+4YPR4KsVlUJgvyVaDcfMITsXjuGlTql39DH0HOGqoGK0K0cuJYrQBgvEdQJtjkOt5BnLvdjkh2xPdpKwKvlMcRIQp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xqf1DK+KcU0mUkp84JEgkE2FYnwMzE3s72rdBAogfqCQRrWdRJwgCQM9fsxYQw3RFko0DZ1EVX4OozFCsSFz/Yf+cfwaW7AfwyNpk4PRXoFQkKhlJmGwXyKwnK6zjSfj31S06xMCUg1eblhYN7xrAtkJ1JnsimBprNZkg2HSdAwiKGqRGEMu1CIc4SFXGq+pjGEQD6Ub5Xkqz5CeEY+5nLcTykzdJ0ZlPKM38/UdJp5LeLeszkjs+aS8soGCsfjKDI1hWVQUKNRrOs68VkWllA5xnAj5zaIBIJgsBA/eTZrAzFCOENImNksty1CKQ+k0yyjKHxSVXmrI616QBzL1V7supKTN5rkjEDNZpG00phhYAnlNww8Y1mYcI6ywSBuBOng+RFxGgBCGAuOsWAzMyJEKR/FWASCQdY0Ps51VeU5n0/IyeVCbzjVJDMvrlsAyyjXAoCklbxQCmOINDcjKh8ZK/r+MQCIEiIsQkTT5CTvw1i0OBBrWls5JJPucM+2YC3S8q6tbhiPDxVuB3qh/IaBBiwL+S0LLXeuNMw5asNYnACAcygVFqVCWkEPBEQ8HBZlIMpm+Pk0tCCY0jbFvWUu7zhLMEgkIJxO2999PJuV9z9BLtz9XDocFolkUsg7zfI2ujtqne+WxVmFKYWSx97fAshj9/cA8rmzcHlO6W8AFmSJUrhFWabCTnl/H1BxMxdrhXJffDZg5lPDWXv/Y5iztrWL/OKPlGX+Bx3qLp1KAjTUAAAAAElFTkSuQmCC';
export default class Map extends Component {
constructor(props){
super(props);
this.state = {
mapOption: null,
provinceJson: require('../../../../../data/map/' + `${props.provinceName}` + '.json') //引入地图的json数据
};
}
componentDidMount() {
let params = {
province: this.props.provinceName,
type: this.props.type
};
this.getMapData(params);
}
getMapData = async (params) => {
let geoCoordMap = {};
this.state.provinceJson.features.forEach((v) => {
var name = v.properties.name;
geoCoordMap[name] = v.properties.cp;
});
let resData = await cityDistribute(params);
let data = resData.map(line =>{if(isNotEmpty(line.region)){return [{ name: line.region, value: line.companyNum }];} });
data = [...data].filter(p=>{if(isNotEmpty(p)){return p;}});
var convertData = function (data) {
var res = [];
for (var i = 0; i < data.length; i++) {
var dataItem = data[i];
var fromCoord = geoCoordMap[dataItem[0].name];
data[i][0]['value'] = [...fromCoord, data[i][0]['value']];
res.push(data[i][0]);
}
return res;
};
data = await convertData(data);
// 过滤数据,从json数据中找出亮点的坐标
this.setChart(data, params);
}
setChart = async (data, params) => {
const mapType = this.props.provinceName;// "四川省"
let option = {
// backgroundColor: '#FAFAFC',
tooltip: {
show: false
},
geo: {
type: 'map',
map: mapType, // "四川省"
show: true,
roam: false, // 不允许平移
label: {
normal: {
show: false,
textStyle: {
color: '#FFFFFF'
}
},
emphasis: {
textStyle: {
color: '#FE8E5C'
}
}
},
zoom: '0.9',
aspectScale: 0.75,
zlevel: 1,
itemStyle: {
normal: {
areaColor: '#2747CB',
borderColor: '#0A2965',
borderWidth: 1,
shadowColor: '#0A2965',
// shadowBlur: 10,
shadowOffsetY: 10, //阴影偏移的位置 上下
shadowOffsetX: 0 //阴影偏移的位置 左右
},
emphasis: {
borderColor: '#FFFFFF',
areaColor: '#1359B3'
}
}
},
series: [
{
type: 'map',
map: mapType,
show: true,
roam: false, // 不允许平移
symbolSize: 10,
label: {
normal: {
show: true,
position: 'bottom',
formatter: e=>{
if(e.value){
return `\r\r\n\n\n${e.name}`;
}else{
return e.name;
}
},
textStyle: {
color: '#1FF1FF'
}
},
emphasis: {
textStyle: {
color: '#FE8E5C'
}
}
},
zoom: '0.9',
aspectScale: 0.75,
zlevel: 1,
itemStyle: {
normal: {
areaColor: '#2747CB',
borderColor: '#0A2965',
borderWidth: 1,
shadowColor: '#0A2965',
// shadowBlur: 10,
shadowOffsetY: 0
},
emphasis: {
borderColor: 'transparent',
areaColor: '#1359B3'
}
},
data: data
},
{
name: '',
type: 'effectScatter',
coordinateSystem: 'geo',
aspectScale: 0.75,
zoom: 0.9,
// symbol: `image://${mapIcon}`,
symbolOffset: [0, 0], // 标记相对于原本位置的偏移。默认情况下,标记会居中置放在数据对应的位置
tooltip: {
show: true,
backgroundColor: 'transparent',
formatter: (item, index) => {
return `<div class=${styles.mapToolTip}>
<h3>${item.name}</h3>
<p><i class=${styles.iconDot}></i>${params.type === 'source' ? '被传导企业数量' : '源头企业数'}:${item.value[2]}家</p>
</div>`;
}
},
show: true,
roam: false,
data: data,
symbolSize: 20,
symbol: iconJG,
showEffectOn: 'render',
rippleEffect: {
brushType: 'stroke'
},
hoverAnimation: true,
label: {
normal: {
formatter: (e)=>{
return e.value[2];
},
position: 'top',
show: true,
textStyle: {
color: '#E6AB05'
}
},
emphasis: {
textStyle: {
color: '#FE8E5C'
}
}
},
itemStyle: { // 圆点
normal: {
color: '#FBDA35',
shadowBlur: 10,
shadowColor: '#FF5F03'
},
emphasis: {
color: '#FE8E5C',
shadowColor: '#FF5F03'
}
},
zlevel: 2
}
]
};
this.setState({ mapOption: { geoJson: this.state.provinceJson, mapType, option } });
}
render() {
let { mapOption } = this.state;
return (
<div style={{width: '100%', height: '100%'}} >
{
mapOption ? !mapOption.option ? null :
<BBDMapChinaDataRange option={mapOption} />
: null
}
</div>
);
}
}
image.png
下载json 数据的 网址:
ttps://gallery.echartsjs.com/editor.html?c=xmCAi_XNuJ
备注:监测预警-风险传导-点击图标-弹窗-点全国地图,下钻到省份地图
网友评论