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 6a7e0e67de..189da6041b 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 @@ -171,7 +171,7 @@ export class BubbleMap extends L7PlotChartView { } dotLayer.addToScene(view.scene) dotLayer.once('add', () => { - mapRendered(container) + mapRendered(container, scene) }) view.scene.map['keyboard'].disable() dotLayer.on('dotLayer:click', (ev: MapMouseEvent) => { 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 ce56f3bdbe..759754171e 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 @@ -109,7 +109,7 @@ export class FlowMap extends L7ChartView { this.startAndEndNameConfig(chart, xAxis, xAxisExt, misc, configList) this.pointConfig(chart, xAxis, xAxisExt, misc, configList) configList[0].once('inited', () => { - mapRendered(container) + mapRendered(container, scene) }) return new L7Wrapper(scene, configList) } 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 f74f33d3b7..22463f7268 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 @@ -14,7 +14,8 @@ import { DEFAULT_BASIC_STYLE } from '@/views/chart/components/editor/util/chart' import { getMapCenter, getMapScene, - getMapStyle + getMapStyle, + mapRendered } from '@/views/chart/components/js/panel/common/common_antv' const { t } = useI18n() @@ -117,6 +118,10 @@ export class HeatMap extends L7ChartView { } }) + config.once('inited', () => { + mapRendered(container, scene) + }) + return new L7Wrapper(scene, config) } 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 7194785104..9380ce026f 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 @@ -1173,13 +1173,27 @@ export class CustomZoom extends Zoom { 'l7-button-control', container, () => { - if (this.controlOption['bounds']) { - this.mapsService.fitBounds(this.controlOption['bounds'], { animate: true }) + if (this.mapsService.map?.deMapProvider == 'qq') { + if (this.mapsService.map.deMapAutoFit) { + this.mapsService.setZoomAndCenter(this.mapsService.map.deMapAutoZoom, [ + this.mapsService.map.deMapAutoLng, + this.mapsService.map.deMapAutoLat + ]) + } else { + this.mapsService.setZoomAndCenter( + this.controlOption['initZoom'], + this.controlOption['center'] + ) + } } else { - this.mapsService.setZoomAndCenter( - this.controlOption['initZoom'], - this.controlOption['center'] - ) + if (this.controlOption['bounds']) { + this.mapsService.fitBounds(this.controlOption['bounds'], { animate: true }) + } else { + this.mapsService.setZoomAndCenter( + this.controlOption['initZoom'], + this.controlOption['center'] + ) + } } } ) @@ -1396,11 +1410,21 @@ export function mapRendering(dom: HTMLElement | string) { dom.classList.add('de-map-rendering') } -export function mapRendered(dom: HTMLElement | string) { +export function mapRendered(dom: HTMLElement | string, scene?: Scene) { if (typeof dom === 'string') { dom = document.getElementById(dom) } dom.classList.add('de-map-rendered') + + if (scene?.map && scene.map.deMapProvider === 'qq') { + setTimeout(() => { + if (scene.map) { + scene.map.deMapAutoZoom = scene.map.getZoom() + scene.map.deMapAutoLng = scene.map.getCenter().getLng() + scene.map.deMapAutoLat = scene.map.getCenter().getLat() + } + }, 1000) + } } export function getMapCenter(basicStyle: ChartBasicStyle) { @@ -1498,6 +1522,11 @@ export async function getMapScene( } if (basicStyle.autoFit === false) { scene.setZoomAndCenter(basicStyle.zoomLevel, center) + if (mapKey.mapType === 'qq') { + scene.map.deMapAutoFit = false + scene.map.deMapZoom = basicStyle.zoomLevel + scene.map.deMapCenter = center + } } } mapRendering(container) @@ -1511,6 +1540,12 @@ export async function getMapScene( //仅渲染:道路及底面(base) + 2d建筑物(building2d),以达到隐藏文字的效果 }) scene.setMapStyle(mapStyle) + + scene.map.deMapProvider = 'qq' + scene.map.deMapAutoFit = !!basicStyle.autoFit + // scene.map.deMapAutoZoom = scene.map.getZoom() + // scene.map.deMapAutoLng = scene.map.getCenter().getLng() + // scene.map.deMapAutoLat = scene.map.getCenter().getLat() } // 去除天地图自己的缩放按钮 if (mapKey.mapType === 'tianditu') {