From 975e42f2eb2bebb540f143286721d66ce0c2e033 Mon Sep 17 00:00:00 2001 From: jianneng-fit2cloud Date: Thu, 28 Nov 2024 19:56:39 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=9B=BE=E8=A1=A8):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E3=80=81=E6=B0=94=E6=B3=A1=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E9=87=8D=E7=BD=AE=E9=BB=98=E8=AE=A4=E7=BC=A9=E6=94=BE=E6=AF=94?= =?UTF-8?q?=E4=BE=8B=E4=B8=8D=E6=AD=A3=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/components/js/panel/charts/map/bubble-map.ts | 5 ++++- .../views/chart/components/js/panel/charts/map/map.ts | 5 ++++- .../chart/components/js/panel/common/common_antv.ts | 10 ++++++++-- 3 files changed, 16 insertions(+), 4 deletions(-) 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