mirror of
https://gitee.com/dromara/go-view.git
synced 2025-02-24 16:22:57 +08:00
feat: 增加可选省份地图(异步会有问题)
This commit is contained in:
parent
2ed1b4bf23
commit
ae4ae074d8
@ -10,6 +10,7 @@ export const option = {
|
|||||||
dataset: dataJson,
|
dataset: dataJson,
|
||||||
mapRegion: {
|
mapRegion: {
|
||||||
adcode: 'china',
|
adcode: 'china',
|
||||||
|
adcodeFlag: true,
|
||||||
},
|
},
|
||||||
tooltip: {
|
tooltip: {
|
||||||
show: true,
|
show: true,
|
||||||
|
@ -76,7 +76,6 @@ const option = reactive({
|
|||||||
const getGeojson = (regionId: string) => {
|
const getGeojson = (regionId: string) => {
|
||||||
return new Promise<boolean>((resolve, reject) => {
|
return new Promise<boolean>((resolve, reject) => {
|
||||||
import(`./mapGeojson/${regionId}.json`).then(data => {
|
import(`./mapGeojson/${regionId}.json`).then(data => {
|
||||||
console.log({data});
|
|
||||||
registerMap(regionId, { geoJSON: data.default as any, specialAreas: {} })
|
registerMap(regionId, { geoJSON: data.default as any, specialAreas: {} })
|
||||||
resolve(true)
|
resolve(true)
|
||||||
})
|
})
|
||||||
@ -87,6 +86,9 @@ registerMap(props.chartConfig.option.mapRegion.adcode, { geoJSON: {} as any, spe
|
|||||||
//保证初始化不报错
|
//保证初始化不报错
|
||||||
const registerMapModulesAsync= async ()=>{
|
const registerMapModulesAsync= async ()=>{
|
||||||
await getGeojson(props.chartConfig.option.mapRegion.adcode)
|
await getGeojson(props.chartConfig.option.mapRegion.adcode)
|
||||||
|
//触发option 变动
|
||||||
|
props.chartConfig.option.mapRegion.adcodeFlag=!props.chartConfig.option.mapRegion.adcodeFlag
|
||||||
|
updateOptions()
|
||||||
}
|
}
|
||||||
registerMapModulesAsync()
|
registerMapModulesAsync()
|
||||||
|
|
||||||
@ -113,9 +115,11 @@ const mapTypeHandle = async (show: boolean) => {
|
|||||||
if (show) {
|
if (show) {
|
||||||
await getGeojson("china")
|
await getGeojson("china")
|
||||||
// registerMap('china', { geoJSON: mapJsonModules["china"] as any, specialAreas: {} })
|
// registerMap('china', { geoJSON: mapJsonModules["china"] as any, specialAreas: {} })
|
||||||
|
props.chartConfig.option.mapRegion.adcodeFlag=!props.chartConfig.option.mapRegion.adcodeFlag
|
||||||
} else {
|
} else {
|
||||||
registerMap('china', { geoJSON: mapJsonWithoutHainanIsLands as any, specialAreas: {} })
|
registerMap('china', { geoJSON: mapJsonWithoutHainanIsLands as any, specialAreas: {} })
|
||||||
}
|
}
|
||||||
|
|
||||||
updateOptions()
|
updateOptions()
|
||||||
}
|
}
|
||||||
//层级发生变化
|
//层级发生变化
|
||||||
|
Loading…
Reference in New Issue
Block a user