一、准备工作
安装 echarts和echarts-gl 命令如下:npm install echarts和npm install echarts-gl npm地址: https://www.npmjs.com/package/echarts https://www.npmjs.com/package/echarts-gl
geo地址获取 http://datav.aliyun.com/portal/school/atlas/area_selector#&lat=31.769817845138945&lng=104.29901249999999&zoom=4
二、简介
1、注册echarts地图
echarts.registerMap('lishui', { geoJSON: lishuiGeoJson });
2、创建echarts实例
const geoChart = echarts.init(document.getElementById('main'));
3、相关配置
const option = {
visualMap: {
min: 1,
max: 15,
text: ['低产值', '高产值'],
realtime: false,
calculable: true,
inRange: {
color: ['#06BB43', '#F86B36']
}
},
series: [
{
type: 'map3D',
name: '丽水地图测试',
map: 'lishui',
regionHeight: 5,
left: '0%',
viewControl: {
rotateSensitivity: 0,
zoomSensitivity: 0,
alpha: 75,
beta: 0,
distance: 120
},
itemStyle: {
normal: {
opacity: 1,
borderWidth: 1,
borderColor: '#162D8B',
label: {
show: true,
textStyle: {
color: '#FFFFFF',
fontSize: 18
}
}
},
emphasis: {
borderWidth: 1.5,
borderColor: '#162D8B',
color: '#F4D417',
label: {
show: true,
textStyle: {
color: '#FFFFFF'
}
}
}
},
shading: 'color',
nameProperty: 'name',
data: [
{ name: '莲都区', adcode: '331102', value: 1 },
{ name: '青田县', adcode: '331121', value: 1 },
{ name: '缙云县', adcode: '331122', value: 1 },
{ name: '遂昌县', adcode: '331123', value: 1 },
{ name: '松阳县', adcode: '331124', value: 1 },
{ name: '云和县', adcode: '331125', value: 1 },
{ name: '庆元县', adcode: '331126', value: 15 },
{ name: '景宁县', adcode: '331127', value: 15 },
{ name: '龙泉市', adcode: '331181', value: 1 }
],
aspectScale: 1.0,
selectedMode: 'single',
hoverable: false,
roam: true
}
]
};
geoChart.setOption(option);
}
4、重要配置说明
a、map
map: ‘lishui’, 注册的地图需要在echart上注册。
b、regionHeight
三维地图的厚度。
c、viewControl
地图控制器 //X轴绕 alpha: 75, //y轴绕 beta: 0, //距离,控制大小 distance: 120
4、itemStyle
控制样式
5、效果
|