获取地图数据:
数据是在DATAV.GeoAtlas中获取的,根据自己的需求随意选择省、市、区,
地图数据获取地址
export const drawMap = (id) => {
let jsonName = hubei
echarts.registerMap('湖北省', jsonName)
let mapChart = echarts.init(
document.getElementById(id)
);
const oprions = {
roamController: {
show: true,
x: 'right',
mapTypeControl: {
'china': true
}
},
geo: {
itemStyle: {
areaColor: 'transparent'
}
},
series: [{
type: 'map',
map: '湖北省',
roam: false,
label: {
normal: {
show: true,
position: "centerTop",
height: 20,
padding: 3,
rich: {
d: {
color: '#fff',
textBorderColor: '#000',
textBorderWidth: 1,
fontSize: 10,
lineHeight: 24,
width: 50,
height: 24,
marginTop: 20,
align: 'center'
},
},
formatter: '{d|{b}}',
textStyle: {
color: "#ccc",
fontSize: "10",
},
},
},
itemStyle: {
normal: {
color: 'transparent',
borderColor: '#3e91be',
areaColor: 'transparent',
areaStyle: { areaColor: 'transparent', },
textStyle: {
color: 'red' //省份字体颜色
}
},
},
data: []
}]
}
mapChart.setOption(oprions);
window.addEventListener("resize", () => {
mapChart.resize();
});
}
获取地图上经纬度的地图工具,用来实现地图上不存在的区域。地图选择器