From 19a97196acad844816b162ee848a89851da7d9c7 Mon Sep 17 00:00:00 2001 From: wisonic Date: Thu, 24 Oct 2024 16:20:40 +0800 Subject: [PATCH] =?UTF-8?q?perf(=E5=9B=BE=E8=A1=A8):=20=E5=9C=A8=E6=83=B3?= =?UTF-8?q?=E5=9C=B0=E5=9B=BE=E5=A4=8D=E7=94=A8=E5=BA=95=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../js/panel/charts/map/flow-map.ts | 35 +++++++++++++------ .../js/panel/charts/map/heat-map.ts | 35 +++++++++++++------ 2 files changed, 48 insertions(+), 22 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/map/flow-map.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/map/flow-map.ts index 5bd92dae69..cdad0642fc 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/map/flow-map.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/map/flow-map.ts @@ -96,18 +96,31 @@ export class FlowMap extends L7ChartView { } const mapKey = await this.getMapKey() // 底层 - const scene = new Scene({ - id: container, - logoVisible: false, - map: new GaodeMap({ - token: mapKey?.key ?? undefined, - style: mapStyle, - pitch: misc.mapPitch, - center, - zoom: basicStyle.autoFit === false ? basicStyle.zoomLevel : 2.5, - showLabel: !(basicStyle.showLabel === false) + const chartObj = drawOption.chartObj as unknown as L7Wrapper + let scene = chartObj?.getScene() + if (!scene) { + scene = new Scene({ + id: container, + logoVisible: false, + map: new GaodeMap({ + token: mapKey?.key ?? undefined, + style: mapStyle, + pitch: misc.mapPitch, + center, + zoom: basicStyle.autoFit === false ? basicStyle.zoomLevel : 2.5, + showLabel: !(basicStyle.showLabel === false) + }) }) - }) + } else { + if (scene.getLayers()?.length) { + await scene.removeAllLayer() + scene.setCenter(center) + scene.setPitch(misc.mapPitch) + scene.setZoom(basicStyle.autoFit === false ? basicStyle.zoomLevel : 2.5) + scene.setMapStyle(mapStyle) + scene.map.showLabel = !(basicStyle.showLabel === false) + } + } mapRendering(container) scene.once('loaded', () => { mapRendered(container) diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/map/heat-map.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/map/heat-map.ts index 8f0b291e96..e935f3e6bb 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/map/heat-map.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/map/heat-map.ts @@ -77,18 +77,31 @@ export class HeatMap extends L7ChartView { } const mapKey = await this.getMapKey() // 底层 - const scene = new Scene({ - id: container, - logoVisible: false, - map: new GaodeMap({ - token: mapKey?.key ?? undefined, - style: mapStyle, - pitch: miscStyle.mapPitch, - center, - zoom: basicStyle.autoFit === false ? basicStyle.zoomLevel : 2.5, - showLabel: !(basicStyle.showLabel === false) + const chartObj = drawOption.chartObj as unknown as L7Wrapper + let scene = chartObj?.getScene() + if (!scene) { + scene = new Scene({ + id: container, + logoVisible: false, + map: new GaodeMap({ + token: mapKey?.key ?? undefined, + style: mapStyle, + pitch: miscStyle.mapPitch, + center, + zoom: basicStyle.autoFit === false ? basicStyle.zoomLevel : 2.5, + showLabel: !(basicStyle.showLabel === false) + }) }) - }) + } else { + if (scene.getLayers()?.length) { + await scene.removeAllLayer() + scene.setCenter(center) + scene.setPitch(miscStyle.mapPitch) + scene.setZoom(basicStyle.autoFit === false ? basicStyle.zoomLevel : 2.5) + scene.setMapStyle(mapStyle) + scene.map.showLabel = !(basicStyle.showLabel === false) + } + } mapRendering(container) scene.once('loaded', () => { mapRendered(container)