提交
This commit is contained in:
@@ -22,14 +22,17 @@ const fetchConfig = async (name: string) => {
|
||||
}
|
||||
// fetchConfig()
|
||||
|
||||
const emit = defineEmits(['getRegionByRegion'])
|
||||
const emit = defineEmits(['getRegionByRegion', 'eliminate'])
|
||||
onMounted(() => {})
|
||||
|
||||
const GetEchar = async (name: string) => {
|
||||
let chartDom = document.getElementById('chartMap')
|
||||
myCharts.value?.resize()
|
||||
myCharts.value?.dispose()
|
||||
myCharts.value = echarts.init(chartDom)
|
||||
echarts.registerMap('china', await fetchConfig(name)) //注册可用的地图
|
||||
if (name != '中国') {
|
||||
showCircle.value = true
|
||||
}
|
||||
echarts.registerMap(name, await fetchConfig(name)) //注册可用的地图
|
||||
let option = {
|
||||
title: {
|
||||
left: 'center',
|
||||
@@ -77,9 +80,10 @@ const GetEchar = async (name: string) => {
|
||||
'#B3B3B3'
|
||||
],
|
||||
geo: {
|
||||
map: 'china',
|
||||
zoom: 1,
|
||||
|
||||
map: name,
|
||||
zoom: 1.2,
|
||||
// top: 0,
|
||||
// bottom: 0,
|
||||
roam: true,
|
||||
label: {
|
||||
normal: {
|
||||
@@ -124,20 +128,20 @@ const GetEchar = async (name: string) => {
|
||||
borderWidth: 0
|
||||
}
|
||||
},
|
||||
regions: [
|
||||
{
|
||||
name: '南海诸岛',
|
||||
itemStyle: {
|
||||
// 隐藏地图
|
||||
normal: {
|
||||
opacity: 0 // 为 0 时不绘制该图形
|
||||
}
|
||||
},
|
||||
label: {
|
||||
show: false // 隐藏文字
|
||||
}
|
||||
}
|
||||
]
|
||||
// regions: [
|
||||
// {
|
||||
// name: '南海诸岛',
|
||||
// itemStyle: {
|
||||
// // 隐藏地图
|
||||
// normal: {
|
||||
// opacity: 0 // 为 0 时不绘制该图形
|
||||
// }
|
||||
// },
|
||||
// label: {
|
||||
// show: false // 隐藏文字
|
||||
// }
|
||||
// }
|
||||
// ]
|
||||
},
|
||||
...props.options.options
|
||||
}
|
||||
@@ -149,9 +153,8 @@ const GetEchar = async (name: string) => {
|
||||
myCharts.value.off('click')
|
||||
myCharts.value.on('click', (e: any) => {
|
||||
if (name == '中国' && e.componentIndex == 0) {
|
||||
GetEchar(e.name)
|
||||
MapReturn(e.name)
|
||||
showCircle.value = true
|
||||
|
||||
// console.log('🚀 ~ file: MyEchartMap.vue:156 ~ myCharts.value.on ~ MapReturn(e.name):', MapReturn(e.name))
|
||||
}
|
||||
})
|
||||
@@ -160,21 +163,26 @@ const GetEchar = async (name: string) => {
|
||||
const MapReturn = (name: string) => {
|
||||
let area = dictData.state.area[0].children
|
||||
let list = {}
|
||||
// break;
|
||||
|
||||
let flag = true
|
||||
|
||||
for (let i = 0; i < area.length; i++) {
|
||||
if (area[i].name == name) {
|
||||
console.log(11111)
|
||||
|
||||
list = area[i]
|
||||
flag = false
|
||||
emit('getRegionByRegion', list)
|
||||
break
|
||||
} else {
|
||||
list = dictData.state.area[0]
|
||||
}
|
||||
}
|
||||
|
||||
emit('getRegionByRegion', list)
|
||||
if (flag) {
|
||||
emit('eliminate', name)
|
||||
}
|
||||
}
|
||||
// 返回
|
||||
const circle = () => {
|
||||
GetEchar('中国')
|
||||
emit('getRegionByRegion', dictData.state.area[0])
|
||||
showCircle.value = false
|
||||
}
|
||||
const resizeHandler = () => {
|
||||
|
||||
Reference in New Issue
Block a user