Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
silianpan committed Sep 12, 2020
1 parent e52daef commit ab8031f
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/packages/map/p-map.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default {
},
data() {
return {
countryLayer: null,
scene: null,
containerId: '',
newOptions: {},
Expand Down Expand Up @@ -63,6 +64,12 @@ export default {
},
beforeDestroy() {
if (this.scene !== null) {
const layers = this.scene.getLayers()
if (layers !== null && layers !== undefined) {
layers.forEach(item => {
this.scene.removeLayer(item)
})
}
this.scene.destroy()
}
},
Expand All @@ -75,7 +82,9 @@ export default {
},
data: {
handler(newVal, oldVal) {
this.updateData()
if (this.countryLayer !== null) {
this.countryLayer.setData(newVal)
}
},
deep: true
}
Expand All @@ -89,23 +98,25 @@ export default {
this.scene.removeLayer(item)
})
}
this.scene.destroy()
this.scene = null
// this.scene.destroy()
// this.scene = null
}
this.newOptions = { ...this.defaultOptions, ...this.options }
this.initChart()
},
initChart() {
this.scene = new Scene({
id: this.containerId,
forceFit: true,
...this.newOptions.chartProps
})
if (this.scene === null) {
this.scene = new Scene({
id: this.containerId,
forceFit: true,
...this.newOptions.chartProps
})
}

const nameOp = this.newOptions.fieldMap.name
const valueOp = this.newOptions.fieldMap.value
this.scene.on('loaded', () => {
new CountryLayer(this.scene, {
this.countryLayer = new CountryLayer(this.scene, {
data: this.data,
joinBy: ['NAME_CHN', nameOp],
depth: 1,
Expand Down

0 comments on commit ab8031f

Please sign in to comment.