mirror of https://gitee.com/antv-l7/antv-l7
improvement: 新增图层按需开取拾取
This commit is contained in:
parent
1b407433d5
commit
a162b4c498
|
@ -104,6 +104,7 @@ export interface ILayer {
|
||||||
options?: ISourceCFG;
|
options?: ISourceCFG;
|
||||||
};
|
};
|
||||||
multiPassRenderer: IMultiPassRenderer;
|
multiPassRenderer: IMultiPassRenderer;
|
||||||
|
needPick(): boolean;
|
||||||
getLayerConfig(): Partial<ILayerConfig & ISceneConfig>;
|
getLayerConfig(): Partial<ILayerConfig & ISceneConfig>;
|
||||||
getContainer(): Container;
|
getContainer(): Container;
|
||||||
setContainer(container: Container): void;
|
setContainer(container: Container): void;
|
||||||
|
|
|
@ -131,7 +131,7 @@ export default class PixelPickingPass<
|
||||||
* TODO:支持区域拾取
|
* TODO:支持区域拾取
|
||||||
*/
|
*/
|
||||||
private pickFromPickingFBO = ({ x, y, lngLat, type }: IInteractionTarget) => {
|
private pickFromPickingFBO = ({ x, y, lngLat, type }: IInteractionTarget) => {
|
||||||
if (!this.layer.isVisible()) {
|
if (!this.layer.isVisible() || !this.layer.needPick()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const {
|
const {
|
||||||
|
|
|
@ -789,6 +789,17 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
|
||||||
return this.layerService.clock.getElapsedTime() - this.animateStartTime;
|
return this.layerService.clock.getElapsedTime() - this.animateStartTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public needPick(): boolean {
|
||||||
|
const {
|
||||||
|
enableHighlight = true,
|
||||||
|
enableSelect = true,
|
||||||
|
} = this.getLayerConfig();
|
||||||
|
const eventNames = this.eventNames().filter((name) => {
|
||||||
|
return name !== 'inited' && name !== 'add' && name !== 'remove';
|
||||||
|
});
|
||||||
|
return eventNames.length > 0 || enableHighlight || enableSelect;
|
||||||
|
}
|
||||||
|
|
||||||
public buildModels() {
|
public buildModels() {
|
||||||
throw new Error('Method not implemented.');
|
throw new Error('Method not implemented.');
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,7 +54,6 @@ export default React.memo(function Map() {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</Scene>
|
</Scene>
|
||||||
/>
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue