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)