Merge pull request #1630 from dataease/pr@v1.6@fix_map_zoom

fix: 地图复位中心点错误
This commit is contained in:
fit2cloud-chenyw 2022-01-12 12:23:34 +08:00 committed by GitHub
commit 38db89444c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -26,7 +26,7 @@ export function baseMapOption(chart_option, chart) {
// 处理data
if (chart.data) {
chart_option.title.text = chart.title
if (chart.data.series.length > 0) {
if (chart.data.series && chart.data.series.length > 0) {
chart_option.series[0].name = chart.data.series[0].name
// label
if (customAttr.label) {

View File

@ -130,7 +130,8 @@ export default {
pointParam: null,
dynamicAreaCode: null,
borderRadius: '0px'
borderRadius: '0px',
mapCenter: null
}
},
@ -276,6 +277,11 @@ export default {
const base_json = JSON.parse(JSON.stringify(BASE_MAP))
const chart_option = baseMapOption(base_json, chart)
this.myEcharts(chart_option)
const opt = this.myChart.getOption()
if (opt && opt.series) {
const center = opt.series[0].center
this.mapCenter = center
}
},
myEcharts(option) {
//
@ -356,6 +362,7 @@ export default {
resetZoom() {
const options = JSON.parse(JSON.stringify(this.myChart.getOption()))
options.series[0].zoom = 1
options.series[0].center = this.mapCenter
this.myChart.setOption(options)
}
}