mirror of https://gitee.com/antv-l7/antv-l7
fix(layer): 更新初始数据为空时,图层不能更新数据
This commit is contained in:
parent
ec7a72a7b2
commit
5ca1fe316e
|
@ -19,6 +19,7 @@ export interface IICONMap {
|
|||
export interface IIconService {
|
||||
canvasHeight: number;
|
||||
on(event: string, fn: EventEmitter.ListenerFn, context?: any): this;
|
||||
off(event: string, fn: EventEmitter.ListenerFn, context?: any): this;
|
||||
init(): void;
|
||||
addImage(id: string, image: IImage): void;
|
||||
hasImage(id: string): boolean;
|
||||
|
|
|
@ -59,6 +59,7 @@ export interface ILayerModel {
|
|||
buildModels(): IModel[];
|
||||
initModels(): IModel[];
|
||||
needUpdate(): boolean;
|
||||
clearModels(): void;
|
||||
}
|
||||
export interface IModelUniform {
|
||||
[key: string]: IUniform;
|
||||
|
|
|
@ -729,6 +729,7 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
|
|||
}
|
||||
public clearModels() {
|
||||
this.models.forEach((model) => model.destroy());
|
||||
this.layerModel.clearModels();
|
||||
}
|
||||
|
||||
public isDirty() {
|
||||
|
|
|
@ -100,6 +100,9 @@ export default class BaseModel<ChildLayerStyleOptions = {}>
|
|||
public initModels(): IModel[] {
|
||||
throw new Error('Method not implemented.');
|
||||
}
|
||||
public clearModels() {
|
||||
return;
|
||||
}
|
||||
public getAttribute(): {
|
||||
attributes: {
|
||||
[attributeName: string]: IAttribute;
|
||||
|
|
|
@ -20,7 +20,7 @@ export default class LayerModelPlugin implements ILayerPlugin {
|
|||
|
||||
layer.clearModels();
|
||||
// 初始化 Model
|
||||
layer.rebuildModels();
|
||||
layer.buildModels();
|
||||
layer.layerModelNeedUpdate = false;
|
||||
return false;
|
||||
});
|
||||
|
|
|
@ -14,8 +14,6 @@ export default class PointLayer extends BaseLayer<IPointLayerStyleOptions> {
|
|||
this.models = this.layerModel.initModels();
|
||||
}
|
||||
public rebuildModels() {
|
||||
// const modelType = this.getModelType();
|
||||
// this.layerModel = new PointModels[modelType](this);
|
||||
this.models = this.layerModel.buildModels();
|
||||
}
|
||||
protected getConfigSchema() {
|
||||
|
|
|
@ -33,13 +33,14 @@ export default class ImageModel extends BaseModel {
|
|||
public initModels(): IModel[] {
|
||||
this.registerBuiltinAttributes();
|
||||
this.updateTexture();
|
||||
this.iconService.on('imageUpdate', () => {
|
||||
this.updateTexture();
|
||||
this.layer.render(); // TODO 调用全局render
|
||||
});
|
||||
this.iconService.on('imageUpdate', this.updateTexture);
|
||||
return this.buildModels();
|
||||
}
|
||||
|
||||
public clearModels() {
|
||||
this.iconService.off('imageUpdate', this.updateTexture);
|
||||
}
|
||||
|
||||
public buildModels(): IModel[] {
|
||||
return [
|
||||
this.layer.buildLayerModel({
|
||||
|
@ -108,7 +109,7 @@ export default class ImageModel extends BaseModel {
|
|||
});
|
||||
}
|
||||
|
||||
private updateTexture() {
|
||||
private updateTexture = () => {
|
||||
const { createTexture2D } = this.rendererService;
|
||||
if (this.texture) {
|
||||
this.texture.destroy();
|
||||
|
@ -120,5 +121,6 @@ export default class ImageModel extends BaseModel {
|
|||
width: 1024,
|
||||
height: this.iconService.canvasHeight || 128,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -142,11 +142,7 @@ export default class TextModel extends BaseModel {
|
|||
}
|
||||
|
||||
public initModels(): IModel[] {
|
||||
this.layer.on('remapping', () => {
|
||||
this.initGlyph();
|
||||
this.updateTexture();
|
||||
this.reBuildModel();
|
||||
});
|
||||
this.layer.on('remapping', this.buildModels);
|
||||
this.extent = this.textExtent();
|
||||
const {
|
||||
textAnchor = 'center',
|
||||
|
@ -159,7 +155,7 @@ export default class TextModel extends BaseModel {
|
|||
return this.buildModels();
|
||||
}
|
||||
|
||||
public buildModels(): IModel[] {
|
||||
public buildModels = () => {
|
||||
this.initGlyph();
|
||||
this.updateTexture();
|
||||
this.filterGlyphs();
|
||||
|
@ -173,7 +169,7 @@ export default class TextModel extends BaseModel {
|
|||
blend: this.getBlend(),
|
||||
}),
|
||||
];
|
||||
}
|
||||
};
|
||||
public needUpdate() {
|
||||
const {
|
||||
textAllowOverlap = false,
|
||||
|
@ -193,6 +189,9 @@ export default class TextModel extends BaseModel {
|
|||
return false;
|
||||
}
|
||||
|
||||
public clearModels() {
|
||||
this.layer.off('remapping', this.buildModels);
|
||||
}
|
||||
protected registerBuiltinAttributes() {
|
||||
this.styleAttributeService.registerStyleAttribute({
|
||||
name: 'textOffsets',
|
||||
|
|
|
@ -55,6 +55,7 @@ export default class Country extends React.Component {
|
|||
},
|
||||
},
|
||||
});
|
||||
console.log(this.drillDown);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -219,12 +219,12 @@ export default class Country extends React.Component {
|
|||
data,
|
||||
geoDataLevel: 1,
|
||||
joinBy: ['adcode', 'code'],
|
||||
adcode: ['330000'],
|
||||
adcode: [],
|
||||
stroke: '#7096B3',
|
||||
depth: 2,
|
||||
showBorder: false,
|
||||
label: {
|
||||
enable: false,
|
||||
enable: true,
|
||||
},
|
||||
fill: {
|
||||
color: '#A3D7FF',
|
||||
|
|
Loading…
Reference in New Issue