this.$nextTick(() => {
const _this = this
if (this.echartMap) {
return
}
// 获取地图数据
axios.get('/json/eerduosi.geoJson').then(res => {
echarts.use([MapChart])
echarts.registerMap('鄂尔多斯', res.data)
this.echartMap = echarts.init(document.getElementById('test1'))
const opotion = {
grid: {
top: 0,
bottom: 0
},
series: [
{
name: '鄂尔多斯',
type: 'map',
mapType: '鄂尔多斯', // #3
itemStyle: {
normal: { label: { show: true }},
emphasis: { label: { show: true }}
},
label: {
normal: {
textStyle: {
fontSize: 10
}
}
}
}
]
}
this.echartMap.setOption(opotion)
// 点击事件,根据点击某个旗区计算出这个旗区的数据
this.echartMap.on('click', function(params) {
// 逻辑控制
res.data.features.forEach(item => {
if (item.properties.name === params.name) {
item.properties.adcode // 点取位置的adcode
}
})
})
})
})
echarts map 获取点击位置的adcode,然后调取接口
最新推荐文章于 2023-08-02 09:33:17 发布