improvement: 新增图层按需开取拾取

This commit is contained in:
thinkinggis 2020-02-12 18:20:39 +08:00
parent 1b407433d5
commit a162b4c498
4 changed files with 13 additions and 2 deletions

View File

@ -104,6 +104,7 @@ export interface ILayer {
options?: ISourceCFG;
};
multiPassRenderer: IMultiPassRenderer;
needPick(): boolean;
getLayerConfig(): Partial<ILayerConfig & ISceneConfig>;
getContainer(): Container;
setContainer(container: Container): void;

View File

@ -131,7 +131,7 @@ export default class PixelPickingPass<
* TODO
*/
private pickFromPickingFBO = ({ x, y, lngLat, type }: IInteractionTarget) => {
if (!this.layer.isVisible()) {
if (!this.layer.isVisible() || !this.layer.needPick()) {
return;
}
const {

View File

@ -789,6 +789,17 @@ export default class BaseLayer<ChildLayerStyleOptions = {}> extends EventEmitter
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() {
throw new Error('Method not implemented.');
}

View File

@ -54,7 +54,6 @@ export default React.memo(function Map() {
/>
)}
</Scene>
/>
</>
);
});