From 6f8db0efca767779504caaf11f389e24e44976ad Mon Sep 17 00:00:00 2001 From: wangxk Date: Tue, 29 Jul 2025 11:36:56 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=81=E7=BA=BF=E5=9B=BE=EF=BC=8C=E7=83=AD?= =?UTF-8?q?=E5=8A=9B=E5=9B=BE=E5=92=8C=E7=AC=A6=E5=8F=B7=E5=9C=B0=E5=9B=BE?= =?UTF-8?q?=E7=9A=84=E5=9C=B0=E5=9B=BE=E5=9C=B0=E5=9B=BE=E6=9B=B4=E6=8D=A2?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/components/editor/util/chart.ts | 14 +- .../components/js/panel/charts/map/common.ts | 1 - .../js/panel/charts/map/flow-map.ts | 101 ++++++++------ .../js/panel/charts/map/heat-map.ts | 128 ++++++++++-------- .../js/panel/charts/map/symbolic-map.ts | 18 ++- 5 files changed, 159 insertions(+), 103 deletions(-) diff --git a/core/core-frontend/src/views/chart/components/editor/util/chart.ts b/core/core-frontend/src/views/chart/components/editor/util/chart.ts index 6f368ca..39446b9 100644 --- a/core/core-frontend/src/views/chart/components/editor/util/chart.ts +++ b/core/core-frontend/src/views/chart/components/editor/util/chart.ts @@ -1575,13 +1575,13 @@ export const CHART_TYPE_CONFIGS = [ title: t('chart.chart_symbolic_map'), icon: 'symbolic-map' }, - { - render: 'antv', - category: 'map', - value: 'three-map', - title: t('chart.three_map'), - icon: 'three-map' - } + // { + // render: 'antv', + // category: 'map', + // value: 'three-map', + // title: t('chart.three_map'), + // icon: 'three-map' + // } ] }, { diff --git a/core/core-frontend/src/views/chart/components/js/panel/charts/map/common.ts b/core/core-frontend/src/views/chart/components/js/panel/charts/map/common.ts index 660526d..e9de26b 100644 --- a/core/core-frontend/src/views/chart/components/js/panel/charts/map/common.ts +++ b/core/core-frontend/src/views/chart/components/js/panel/charts/map/common.ts @@ -63,7 +63,6 @@ export const gaodeMapStyleOptions = [ { name: t('chart.map_style_fresh'), value: 'fresh' }, { name: t('chart.map_style_grey'), value: 'grey' }, { name: t('chart.map_style_blue'), value: 'blue' }, - { name: t('chart.map_style_translate'), value: 'Satellite' }, { name: t('commons.custom'), value: 'custom' } ] 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 e53d3de..c3fbc5d 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,8 +12,10 @@ import { GaodeMap } from '@antv/l7-maps' import { Scene } from '@antv/l7-scene' import { LineLayer } from '@antv/l7-layers' import { PointLayer } from '@antv/l7-layers' -import { mapRendered, mapRendering } from '@/views/chart/components/js/panel/common/common_antv' +import { mapRendered, mapRendering,getMapScene } from '@/views/chart/components/js/panel/common/common_antv' import { DEFAULT_BASIC_STYLE } from '@/views/chart/components/editor/util/chart' +import { storeToRefs } from 'pinia' +import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain' const { t } = useI18n() /** @@ -87,7 +89,6 @@ export class FlowMap extends L7ChartView { const xAxis = deepCopy(chart.xAxis) const xAxisExt = deepCopy(chart.xAxisExt) const { basicStyle, misc } = deepCopy(parseJson(chart.customAttr)) - let center: [number, number] = [ DEFAULT_BASIC_STYLE.mapCenter.longitude, DEFAULT_BASIC_STYLE.mapCenter.latitude @@ -99,47 +100,67 @@ export class FlowMap extends L7ChartView { if (basicStyle.mapStyle !== 'custom') { mapStyle = `amap://styles/${basicStyle.mapStyle ? basicStyle.mapStyle : 'normal'}` } - const mapKey = await this.getMapKey() + const dvMainStore = dvMainStoreWithOut() + const { + curComponent + } = storeToRefs(dvMainStore) + let mapKey: any + if (curComponent.value && curComponent.value.mapServer) { + mapKey = curComponent.value.mapServer.find(server => server.status === true); + } else { + let allmapKey = await this.idGetMapKey(chart.id) + mapKey = allmapKey.find(server => server.status === true); + } // 底层 const chartObj = drawOption.chartObj as unknown as L7Wrapper let scene = chartObj?.getScene() - if(scene){ - if (scene.getLayers()?.length) { - await scene.removeAllLayer() - scene.setPitch(misc.mapPitch) - } - } - if (mapStyle.indexOf('Satellite') == -1) { - 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 : undefined, - showLabel: !(basicStyle.showLabel === false), - WebGLParams: { - preserveDrawingBuffer: true - } - }) - }) - }else{ - scene = new Scene({ - id: container, - logoVisible: false, - map: new GaodeMap({ - token: mapKey?.key ?? undefined, - style: mapStyle, - features: ['bg', 'road'], // 必须开启路网层 - plugin: ['AMap.TileLayer.Satellite'], // 显式声明卫星图层 - WebGLParams: { - preserveDrawingBuffer: true - } - }) - }) - } + scene = await getMapScene( + chart, + scene, + container, + mapKey, + basicStyle, + misc, + mapStyle, + center + ) + // if(scene){ + // if (scene.getLayers()?.length) { + // await scene.removeAllLayer() + // scene.setPitch(misc.mapPitch) + // } + // } + // if (mapStyle.indexOf('Satellite') == -1) { + // 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 : undefined, + // showLabel: !(basicStyle.showLabel === false), + // WebGLParams: { + // preserveDrawingBuffer: true + // } + // }) + // }) + // }else{ + // scene = new Scene({ + // id: container, + // logoVisible: false, + // map: new GaodeMap({ + // token: mapKey?.key ?? undefined, + // style: mapStyle, + // features: ['bg', 'road'], // 必须开启路网层 + // plugin: ['AMap.TileLayer.Satellite'], // 显式声明卫星图层 + // WebGLParams: { + // preserveDrawingBuffer: true + // } + // }) + // }) + // } // if (!scene) { // scene = new Scene({ // id: 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 088db46..fa9c89d 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 @@ -12,7 +12,9 @@ import { GaodeMap } from '@antv/l7-maps' import { Scene } from '@antv/l7-scene' import { HeatmapLayer } from '@antv/l7-layers' import { DEFAULT_BASIC_STYLE } from '@/views/chart/components/editor/util/chart' -import { mapRendered, mapRendering } from '@/views/chart/components/js/panel/common/common_antv' +import { mapRendered, mapRendering, getMapScene } from '@/views/chart/components/js/panel/common/common_antv' +import { storeToRefs } from 'pinia' +import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain' const { t } = useI18n() /** @@ -80,48 +82,68 @@ export class HeatMap extends L7ChartView { if (basicStyle.mapStyle !== 'custom') { mapStyle = `amap://styles/${basicStyle.mapStyle ? basicStyle.mapStyle : 'normal'}` } - const mapKey = await this.getMapKey() + const dvMainStore = dvMainStoreWithOut() + const { + curComponent + } = storeToRefs(dvMainStore) + let mapKey: any + if (curComponent.value && curComponent.value.mapServer) { + mapKey = curComponent.value.mapServer.find(server => server.status === true); + } else { + let allmapKey = await this.idGetMapKey(chart.id) + mapKey = allmapKey.find(server => server.status === true); + } // 底层 const chartObj = drawOption.chartObj as unknown as L7Wrapper let scene = chartObj?.getScene() - if(scene){ - if (scene.getLayers()?.length) { - await scene.removeAllLayer() - scene.setPitch(miscStyle.mapPitch) - } - } - - if (mapStyle.indexOf('Satellite') == -1) { - 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 : undefined, - showLabel: !(basicStyle.showLabel === false), - WebGLParams: { - preserveDrawingBuffer: true - } - }) - }) - } else { - scene = new Scene({ - id: container, - logoVisible: false, - map: new GaodeMap({ - token: mapKey?.key ?? undefined, - style: mapStyle, - features: ['bg', 'road'], // 必须开启路网层 - plugin: ['AMap.TileLayer.Satellite'], // 显式声明卫星图层 - WebGLParams: { - preserveDrawingBuffer: true - } - }) - }) - } + scene = await getMapScene( + chart, + scene, + container, + mapKey, + basicStyle, + miscStyle, + mapStyle, + center + ) + // if(scene){ + // if (scene.getLayers()?.length) { + // await scene.removeAllLayer() + // scene.setPitch(miscStyle.mapPitch) + // } + // } + + // if (mapStyle.indexOf('Satellite') == -1) { + // 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 : undefined, + // showLabel: !(basicStyle.showLabel === false), + // WebGLParams: { + // preserveDrawingBuffer: true + // } + // }) + // }) + // } else { + // scene = new Scene({ + // id: container, + // logoVisible: false, + // map: new GaodeMap({ + // token: mapKey?.key ?? undefined, + // style: mapStyle, + // features: ['bg', 'road'], // 必须开启路网层 + // plugin: ['AMap.TileLayer.Satellite'], // 显式声明卫星图层 + // WebGLParams: { + // preserveDrawingBuffer: true + // } + // }) + // }) + // } // } else { // // if (scene.getLayers()?.length) { @@ -135,19 +157,19 @@ export class HeatMap extends L7ChartView { // // } // } mapRendering(container) - if (mapStyle.indexOf('Satellite') == -1) { - scene.once('loaded', () => { - mapRendered(container) - }) - } else { - scene.once('loaded', () => { - // 创建卫星图层实例 - const satelliteLayer = new AMap.TileLayer.Satellite() - // 与矢量图层叠加显示 - satelliteLayer.setMap(scene.map) - mapRendered(container) - }) - } + // if (mapStyle.indexOf('Satellite') == -1) { + // scene.once('loaded', () => { + // mapRendered(container) + // }) + // } else { + // scene.once('loaded', () => { + // // 创建卫星图层实例 + // const satelliteLayer = new AMap.TileLayer.Satellite() + // // 与矢量图层叠加显示 + // satelliteLayer.setMap(scene.map) + // mapRendered(container) + // }) + // } this.configZoomButton(chart, scene) if (xAxis?.length < 2 || yAxis?.length < 1) { 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 6493e38..c6c9c3b 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 @@ -25,6 +25,8 @@ import { } from '@/views/chart/components/js/panel/common/common_antv' import { configCarouselTooltip } from '@/views/chart/components/js/panel/charts/map/tooltip-carousel' import { filter } from 'lodash-es' +import { storeToRefs } from 'pinia' +import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain' const { t } = useI18n() /** @@ -105,8 +107,20 @@ export class SymbolicMap extends L7ChartView { basicStyle = parseJson(chart.customAttr).basicStyle miscStyle = parseJson(chart.customAttr).misc } - - const mapKey = await this.getMapKey() + // beijing:beijing3 + // http://192.168.1.70:8080/geoserver/beijing + // const mapKey = await this.getMapKey() + const dvMainStore = dvMainStoreWithOut() + const { + curComponent + } = storeToRefs(dvMainStore) + let mapKey: any + if (curComponent.value && curComponent.value.mapServer) { + mapKey = curComponent.value.mapServer.find(server => server.status === true); + } else { + let allmapKey = await this.idGetMapKey(chart.id) + mapKey = allmapKey.find(server => server.status === true); + } const mapStyle = getMapStyle(mapKey, basicStyle) let center = getMapCenter(basicStyle)