fix: 修复npm-location地图下钻bug

This commit is contained in:
chenjinsong
2022-08-25 18:59:26 +08:00
parent ebcc77312b
commit 12ea5dc160

View File

@@ -63,9 +63,9 @@ export default {
locationOptions, locationOptions,
myChart: null, myChart: null,
polygonSeries: null, polygonSeries: null,
countrySeries: null, countrySeries: [],
worldImageSeries: null, worldImageSeries: null,
countryImageSeries: null, countryImageSeries: [],
// Server | Client // Server | Client
trafficDirection: 'Server', trafficDirection: 'Server',
location: '' location: ''
@@ -94,17 +94,20 @@ export default {
this.worldImageSeries.mapImages.template.events.on('hit', async ev => { this.worldImageSeries.mapImages.template.events.on('hit', async ev => {
this.$store.commit('setNpmLocationCountry', ev.target.dataItem.dataContext.name) this.$store.commit('setNpmLocationCountry', ev.target.dataItem.dataContext.name)
this.location = ev.target.dataItem.dataContext.name this.location = ev.target.dataItem.dataContext.name
if (this.countrySeries) { this.cleanCountry()
this.countrySeries.dispose()
}
if (this.countryImageSeries) {
this.countryImageSeries.dispose()
}
const countryId = ev.target.dataItem.dataContext.id const countryId = ev.target.dataItem.dataContext.id
ev.target.isHover = false ev.target.isHover = false
await this.drill(countryId) await this.drill(countryId)
}) })
}, },
cleanCountry () {
this.countrySeries.forEach(s => {
s.value.dispose()
})
this.countryImageSeries.forEach(s => {
s.value.dispose()
})
},
loadAm4ChartMap (polygonSeries, imageSeries) { loadAm4ChartMap (polygonSeries, imageSeries) {
try { try {
// 清除数据 // 清除数据
@@ -267,13 +270,15 @@ export default {
targetMapObject.series.chart.zoomToMapObject(targetMapObject) targetMapObject.series.chart.zoomToMapObject(targetMapObject)
const geoData = await getGeoData(countryId) const geoData = await getGeoData(countryId)
if (geoData) { if (geoData) {
this.countrySeries = shallowRef(this.polygonSeriesFactory()) const countrySeries = shallowRef(this.polygonSeriesFactory())
this.countrySeries.geodata = geoData countrySeries.value.geodata = geoData
this.countryImageSeries = shallowRef(this.imageSeriesFactory('score', this.countrySeries)) const countryImageSeries = shallowRef(this.imageSeriesFactory('score', countrySeries.value))
this.countrySeries.push(countrySeries)
this.countryImageSeries.push(countryImageSeries)
this.polygonSeries.hide() this.polygonSeries.hide()
this.worldImageSeries.hide() this.worldImageSeries.hide()
this.$nextTick(() => { this.$nextTick(() => {
this.loadAm4ChartMap(this.countrySeries, this.countryImageSeries) this.loadAm4ChartMap(countrySeries.value, countryImageSeries.value)
}) })
} }
} }
@@ -290,12 +295,7 @@ export default {
}, },
async location (n) { async location (n) {
this.$store.commit('setNpmLocationCountry', n) this.$store.commit('setNpmLocationCountry', n)
if (this.countrySeries) { this.cleanCountry()
this.countrySeries.dispose()
}
if (this.countryImageSeries) {
this.countryImageSeries.dispose()
}
if (n) { if (n) {
const countryId = countryNameIdMapping[n] const countryId = countryNameIdMapping[n]
await this.drill(countryId) await this.drill(countryId)