3级地图优化

This commit is contained in:
mouse 2023-12-24 12:29:35 +08:00
parent e4e795e774
commit 0edba5a83b
2 changed files with 12 additions and 4 deletions

View File

@ -18,16 +18,24 @@ onMounted(() => {
defineExpose({
setMap
})
function setMap(name: string) {
function adcodeFormatter(code: string) {
let str = code;
if(str.slice(-2) === '00') str = str.slice(0, -2)
return str
}
function setMap(name: string, totalData: any) {
getMapJson(name + '_full.json').then((res: any) => {
const chinaJson = res.data
const data: any = []
const markData: any = []
console.log(totalData)
console.log(chinaJson.features)
chinaJson.features.forEach((item: any, index: number) => {
const key = adcodeFormatter(item.properties.adcode + '')
console.log(key)
const obj = {
name: item.properties.name,
value: Math.ceil(Math.random() * 30)
value: totalData.c[key] ? totalData.c[key].t || 0 : 0
}
data.push(obj)
markData.push({

View File

@ -48,7 +48,7 @@ function initCitys(data: any, adcode: string) {
//
isCityMap.value = true
setTimeout(() => {
cityMapChartRef.value.setMap(adcode + '0000')
cityMapChartRef.value.setMap(adcode + '0000', data)
}, 0)
}
//