fix: 修复 LayerSwitch 展示图层变更时触发两次的问题 (#1415)

* refactor: 1.控件 LayerControl => LayerSwitch,防止在 LarkMap 中控件命名概念混淆  2.LayerSwitch 的参数 layers 新增支持传递 layer 的 id 数组

* fix: 修复 l7-component 打包依赖报错问题

* fix: 修复 LayerControl 展示图层变更会触发两次的问题

Co-authored-by: yanxiong <oujinhui.ojh@antgroup.com>
This commit is contained in:
heiyexing 2022-10-20 15:30:27 +08:00 committed by GitHub
parent a94f12b60f
commit 36b542e358
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 20 deletions

View File

@ -64,12 +64,8 @@ export default class LayerSwitch extends SelectControl<ILayerSwitchOption> {
public setOptions(option: Partial<ILayerSwitchOption>) {
const isLayerChange = this.checkUpdateOption(option, ['layers']);
if (isLayerChange) {
this.unbindLayerVisibleCallback();
}
super.setOptions(option);
if (isLayerChange) {
this.bindLayerVisibleCallback();
this.selectValue = this.getLayerVisible();
this.controlOption.options = this.getLayerOptions();
this.popper.setContent(this.getPopperContent(this.controlOption.options));
@ -85,28 +81,12 @@ export default class LayerSwitch extends SelectControl<ILayerSwitchOption> {
}
this.on('selectChange', this.onSelectChange);
this.layerService.on('layerChange', this.onLayerChange);
this.bindLayerVisibleCallback();
return super.onAdd();
}
public bindLayerVisibleCallback = () => {
this.layers.forEach((layer) => {
layer.on('show', this.onLayerVisibleChane);
layer.on('hide', this.onLayerVisibleChane);
});
};
public unbindLayerVisibleCallback = () => {
this.layers.forEach((layer) => {
layer.off('show', this.onLayerVisibleChane);
layer.off('hide', this.onLayerVisibleChane);
});
};
public onRemove() {
this.off('selectChange', this.onSelectChange);
this.layerService.off('layerChange', this.onLayerChange);
this.unbindLayerVisibleCallback();
}
protected onLayerChange = () => {