fix(图表): 修复地图、气泡地图重置默认缩放比例不正确的问题

This commit is contained in:
jianneng-fit2cloud
2024-11-28 19:56:39 +08:00
parent 8462475c7c
commit 975e42f2eb
3 changed files with 16 additions and 4 deletions

View File

@@ -158,7 +158,10 @@ export class BubbleMap extends L7PlotChartView<ChoroplethOptions, Choropleth> {
if (!areaId.startsWith('custom_')) {
dotLayer.options = { ...dotLayer.options, tooltip }
}
this.configZoomButton(chart, view)
// 完成地图渲染后配置缩放按钮,为了能够获取到默认的缩放比例
view.on('loaded', () => {
this.configZoomButton(chart, view)
})
mapRendering(container)
view.once('loaded', () => {
// 修改地图鼠标样式为默认

View File

@@ -208,7 +208,10 @@ export class Map extends L7PlotChartView<ChoroplethOptions, Choropleth> {
options = this.setupOptions(chart, options, context)
const { Choropleth } = await import('@antv/l7plot/dist/esm/plots/choropleth')
const view = new Choropleth(container, options)
this.configZoomButton(chart, view)
// 完成地图渲染后配置缩放按钮,为了能够获取到默认的缩放比例
view.on('loaded', () => {
this.configZoomButton(chart, view)
})
mapRendering(container)
view.once('loaded', () => {
mapRendered(container)

View File

@@ -1180,9 +1180,15 @@ export function configL7Zoom(chart: Chart, plot: L7Plot<PlotOptions> | Scene) {
return
}
if (!plotScene?.getControlByName('zoom')) {
let initZoom = basicStyle.autoFit === false ? basicStyle.zoomLevel : 2.5
let center = getCenter(basicStyle)
if (['map', 'bubble-map'].includes(chart.type)) {
initZoom = plotScene.getZoom()
center = plotScene.getCenter()
}
const newZoomOptions = {
initZoom: basicStyle.autoFit === false ? basicStyle.zoomLevel : 2.5,
center: getCenter(basicStyle),
initZoom: initZoom,
center: center,
buttonColor: basicStyle.zoomButtonColor,
buttonBackground: basicStyle.zoomBackground
} as any