fix: 修复 option 参数未同步 style 更新导致的配置失效 (#1226)

* feat: 去处事件节流

* fix: 修复 option 参数未同步 style 更新导致的配置失效

* style: lint style
This commit is contained in:
YiQianYao 2022-07-08 17:45:55 +08:00 committed by GitHub
parent 0df9edfbb5
commit ef683c9142
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -246,6 +246,9 @@ export default class BaseLayer<ChildLayerStyleOptions = {}>
public updateLayerConfig(
configToUpdate: Partial<ILayerConfig | ChildLayerStyleOptions>,
) {
// 同步 options 记录
this.updateRawConfig(configToUpdate);
if (!this.inited) {
this.needUpdateConfig = {
...this.needUpdateConfig,
@ -1312,6 +1315,18 @@ export default class BaseLayer<ChildLayerStyleOptions = {}>
return {};
}
private updateRawConfig(
configToUpdate: Partial<ILayerConfig | ChildLayerStyleOptions>,
) {
Object.keys(configToUpdate).map((key) => {
// @ts-ignore
if (this.rawConfig[key] && this.rawConfig[key] !== configToUpdate[key]) {
// @ts-ignore
this.rawConfig[key] = configToUpdate[key];
}
});
}
private sourceEvent = () => {
this.dataState.dataSourceNeedUpdate = true;
const { autoFit, fitBoundsOptions } = this.getLayerConfig();