From dd390883963a56c4ed6932ad1e8e2b1714b44bd2 Mon Sep 17 00:00:00 2001 From: wisonic-s Date: Wed, 26 Jun 2024 19:05:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E5=9B=BE=E8=A1=A8):=20=E5=9C=B0?= =?UTF-8?q?=E5=9B=BE=E5=8A=A0=E8=BD=BD=E5=AE=8C=E6=88=90=E6=A0=87=E8=AF=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/components/js/panel/charts/map/bubble-map.ts | 10 +++++++++- .../chart/components/js/panel/charts/map/flow-map.ts | 8 ++++++++ .../chart/components/js/panel/charts/map/heat-map.ts | 7 +++++-- .../views/chart/components/js/panel/charts/map/map.ts | 9 +++++++-- .../components/js/panel/charts/map/symbolic-map.ts | 5 +++++ 5 files changed, 34 insertions(+), 5 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 ac93b3476d..d6d56d75c1 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 @@ -15,7 +15,11 @@ import { import { flow, getGeoJsonFile, hexColorToRGBA, parseJson } from '@/views/chart/components/js/util' import { cloneDeep } from 'lodash-es' import { FeatureCollection } from '@antv/l7plot/dist/esm/plots/choropleth/types' -import { handleGeoJson } from '@/views/chart/components/js/panel/common/common_antv' +import { + handleGeoJson, + mapRendered, + mapRendering +} from '@/views/chart/components/js/panel/common/common_antv' import { valueFormatter } from '@/views/chart/components/js/formatter' const { t } = useI18n() @@ -100,8 +104,12 @@ export class BubbleMap extends L7PlotChartView { const view = new Choropleth(container, options) const dotLayer = this.getDotLayer(chart, geoJson, drawOption) this.configZoomButton(chart, view) + mapRendering(container) view.once('loaded', () => { view.addLayer(dotLayer) + dotLayer.once('add', () => { + mapRendered(container) + }) view.scene.map['keyboard'].disable() view.on('fillAreaLayer:click', (ev: MapMouseEvent) => { const data = ev.feature.properties 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 2bc9f602a0..9ef53a7bae 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 @@ -12,6 +12,7 @@ import { GaodeMap } from '@antv/l7-maps' import { Scene } from '@antv/l7-scene' import { LineLayer } from '@antv/l7-layers' import { queryMapKeyApi } from '@/api/setting/sysParameter' +import { mapRendered, mapRendering } from '@/views/chart/components/js/panel/common/common_antv' const { t } = useI18n() /** @@ -77,6 +78,10 @@ export class FlowMap extends L7ChartView { zoom: 2.5 }) }) + mapRendering(container) + scene.once('loaded', () => { + mapRendered(container) + }) if (xAxis?.length < 2 || xAxisExt?.length < 2) { return new L7Wrapper(scene, undefined) } @@ -115,6 +120,9 @@ export class FlowMap extends L7ChartView { }) .color(flowLineStyle.sourceColor) } + config.once('inited', () => { + mapRendered(container) + }) this.configZoomButton(chart, scene) return new L7Wrapper(scene, config) } 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 8f801f092e..2a97abdaec 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 @@ -13,6 +13,7 @@ import { Scene } from '@antv/l7-scene' import { HeatmapLayer } from '@antv/l7-layers' import { queryMapKeyApi } from '@/api/setting/sysParameter' import { DEFAULT_BASIC_STYLE } from '@/views/chart/components/editor/util/chart' +import { mapRendered, mapRendering } from '@/views/chart/components/js/panel/common/common_antv' const { t } = useI18n() /** @@ -55,7 +56,6 @@ export class HeatMap extends L7ChartView { basicStyle = parseJson(chart.customAttr).basicStyle miscStyle = parseJson(chart.customAttr).misc } - console.log(basicStyle) const mapStyle = `amap://styles/${basicStyle.mapStyle ? basicStyle.mapStyle : 'normal'}` const key = await this.getMapKey() // 底层 @@ -69,10 +69,13 @@ export class HeatMap extends L7ChartView { zoom: 2.5 }) }) + mapRendering(container) + scene.once('loaded', () => { + mapRendered(container) + }) if (xAxis?.length < 2 || yAxis?.length < 1) { return new L7Wrapper(scene, undefined) } - console.log(chart.data?.data) const config: L7Config = new HeatmapLayer({ name: 'line', blend: 'normal', 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 8b8126763a..5452e06c47 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 @@ -12,7 +12,11 @@ import { hexColorToRGBA, parseJson } from '@/views/chart/components/js/util' -import { handleGeoJson } from '@/views/chart/components/js/panel/common/common_antv' +import { + handleGeoJson, + mapRendered, + mapRendering +} from '@/views/chart/components/js/panel/common/common_antv' import { FeatureCollection } from '@antv/l7plot/dist/esm/plots/choropleth/types' import { cloneDeep } from 'lodash-es' import { useI18n } from '@/hooks/web/useI18n' @@ -133,7 +137,9 @@ export class Map extends L7PlotChartView { options = this.setupOptions(chart, options, context) const view = new Choropleth(container, options) this.configZoomButton(chart, view) + mapRendering(container) view.once('loaded', () => { + mapRendered(container) view.scene.map['keyboard'].disable() view.on('fillAreaLayer:click', (ev: MapMouseEvent) => { const data = ev.feature.properties @@ -147,7 +153,6 @@ export class Map extends L7PlotChartView { }) }) }) - return view } diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/map/symbolic-map.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/map/symbolic-map.ts index eeb321c0da..7e697da7a5 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/map/symbolic-map.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/map/symbolic-map.ts @@ -13,6 +13,7 @@ import { Scene } from '@antv/l7-scene' import { PointLayer } from '@antv/l7-layers' import { LayerPopup } from '@antv/l7' import { queryMapKeyApi } from '@/api/setting/sysParameter' +import { mapRendered, mapRendering } from '@/views/chart/components/js/panel/common/common_antv' const { t } = useI18n() /** @@ -81,6 +82,10 @@ export class SymbolicMap extends L7ChartView { zoom: 1.8 }) }) + mapRendering(container) + scene.once('loaded', () => { + mapRendered(container) + }) if (xAxis?.length < 2 || xAxisExt?.length < 1) { return new L7Wrapper(scene, undefined) }