diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/map/bubble-map.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/map/bubble-map.ts index b7d4ed018b..0a17769471 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/map/bubble-map.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/map/bubble-map.ts @@ -158,7 +158,10 @@ export class BubbleMap extends L7PlotChartView { if (!areaId.startsWith('custom_')) { dotLayer.options = { ...dotLayer.options, tooltip } } - this.configZoomButton(chart, view) + // 完成地图渲染后配置缩放按钮,为了能够获取到默认的缩放比例 + view.on('loaded', () => { + this.configZoomButton(chart, view) + }) mapRendering(container) view.once('loaded', () => { // 修改地图鼠标样式为默认 diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/map/map.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/map/map.ts index 2ca0434a23..a45373f361 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/map/map.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/map/map.ts @@ -208,7 +208,10 @@ export class Map extends L7PlotChartView { options = this.setupOptions(chart, options, context) const { Choropleth } = await import('@antv/l7plot/dist/esm/plots/choropleth') const view = new Choropleth(container, options) - this.configZoomButton(chart, view) + // 完成地图渲染后配置缩放按钮,为了能够获取到默认的缩放比例 + view.on('loaded', () => { + this.configZoomButton(chart, view) + }) mapRendering(container) view.once('loaded', () => { mapRendered(container) diff --git a/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts b/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts index 53fe64c276..ed51500ae8 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/common/common_antv.ts @@ -1180,9 +1180,15 @@ export function configL7Zoom(chart: Chart, plot: L7Plot | Scene) { return } if (!plotScene?.getControlByName('zoom')) { + let initZoom = basicStyle.autoFit === false ? basicStyle.zoomLevel : 2.5 + let center = getCenter(basicStyle) + if (['map', 'bubble-map'].includes(chart.type)) { + initZoom = plotScene.getZoom() + center = plotScene.getCenter() + } const newZoomOptions = { - initZoom: basicStyle.autoFit === false ? basicStyle.zoomLevel : 2.5, - center: getCenter(basicStyle), + initZoom: initZoom, + center: center, buttonColor: basicStyle.zoomButtonColor, buttonBackground: basicStyle.zoomBackground } as any