新增自定义颜色方案

This commit is contained in:
JIANG
2025-11-20 18:34:54 +08:00
parent 11ccd53672
commit 23154b2b5f
3 changed files with 167 additions and 16 deletions

View File

@@ -11,9 +11,18 @@ export class DeckLayer extends Layer {
private onVisibilityChange?: (layerId: string, visible: boolean) => void;
private userVisibility: Map<string, boolean> = new Map(); // 存储用户设置的可见性
constructor(deckInstance: Deck) {
super({});
/**
* @param deckInstance deck.gl 实例
* @param layerProperties 可选:在构造时直接设置到 OpenLayers Layer 的 properties
*/
constructor(deckInstance: Deck, layerProperties?: Record<string, any>) {
// 将 layerProperties 作为 Layer 的 properties 传入
super({ properties: layerProperties || {} });
this.deck = deckInstance;
// 再次确保属性应用到实例(兼容场景)
if (layerProperties) {
this.setProperties(layerProperties);
}
}
// 设置可见性变化回调
@@ -118,4 +127,9 @@ export class DeckLayer extends Layer {
this.setDeckLayerVisible(layerId, !currentVisible);
}
}
// 可选的封装:在外部用更语义化的方式设置属性(内部可直接调用 setProperties
setLayerProperties(props: Record<string, any>): void {
this.setProperties(props);
}
}