echarts-gl在渲染3d地图后,进行点击事件获取不到点击事件,排查后发现是因为数据没有放在series中,所以获取不到数据,将数据放入到series中后就可以正常获取点击事件了。
实例代码
drawEcharts() {
var that = this;
if (this.myChart) {
this.myChart.dispose()
}
var chartDom = that.$refs.centerMap;
var myChart = this.myChart = echarts.init(chartDom);
myChart.clear()
myChart.resize()
var nameMap = '地图数据';
// 图标数据
echarts.registerMap(nameMap, this.mapData);
var optionMap = {
series: [{
map: nameMap,
type: "map3D",
roam: true,
itemStyle: {
color: '#6089d1',
borderWidth: 0.8,
borderColor: '#a9dbff'
},
emphasis: {
itemStyle: {
color: '#ddb84c'
},
},
label: {
show: true,
color: '#fff', //地图初始化区域字体颜色
fontSize: 14,
opacity: 1,
},
}]
};
myChart.clear()
myChart.resize()
myChart.setOption(optionMap);
myChart.on('click', params => {
that.areaName = params.name
that.getCode()
})
}