fix(react): 更新数据源之后是否需要自适应配置项开启

This commit is contained in:
聆一 2020-02-27 08:21:27 +08:00
parent 2686c48881
commit 7167c3197e
3 changed files with 7 additions and 4 deletions

View File

@ -60,10 +60,6 @@ export default function BaseLayer(type: string, props: ILayerProps) {
// 重绘layer
if (layer) {
mapScene.render();
// 如果autoFit为true执行自适应操作
if (options?.autoFit) {
layer.fitBounds();
}
}
});

View File

@ -17,6 +17,11 @@ export default React.memo(function Chart(props: ISourceProps) {
} else {
layer.setData(data, sourceOption);
}
// 临时解决:若开启,每次更新之后自适应缩放;
// TODO是否可以统一到Layer的option里目前问题是Layer的autoFit一直为true无法触发更新
if (sourceOption.autoFit) {
layer.fitBounds();
}
}, [data, JSON.stringify(sourceOption)]);
return null;
});

View File

@ -49,6 +49,8 @@ export interface IStyleOptions {
export interface ISourceOptions extends ISourceCFG {
data: any;
// 每次更新数据之后是否自适应缩放
autoFit: boolean;
}
export interface IActiveOptions {