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; 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;

View File

@ -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 {

View File

@ -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.');
} }

View File

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