fix: layer 拾取 fix #191

This commit is contained in:
thinkinggis 2020-02-07 22:12:56 +08:00
parent 2e8e54727b
commit 9c7d9e902c
3 changed files with 15 additions and 14 deletions

View File

@ -209,18 +209,18 @@ export default class PixelPickingPass<
this.triggerHoverOnLayer(target); this.triggerHoverOnLayer(target);
this.layer.setCurrentPickId(null); this.layer.setCurrentPickId(null);
} }
});
if (enableHighlight) { if (enableHighlight) {
this.highlightPickedFeature(pickedColors); this.highlightPickedFeature(pickedColors);
} }
if ( if (
enableSelect && enableSelect &&
type === 'click' && type === 'click' &&
pickedColors?.toString() !== [0, 0, 0, 0].toString() pickedColors?.toString() !== [0, 0, 0, 0].toString()
) { ) {
this.selectFeature(pickedColors); this.selectFeature(pickedColors);
} }
});
}; };
private triggerHoverOnLayer(target: { private triggerHoverOnLayer(target: {

View File

@ -49,9 +49,7 @@ export default class PixelPickingPlugin implements ILayerPlugin {
update: (feature: IEncodeFeature, featureIdx: number) => { update: (feature: IEncodeFeature, featureIdx: number) => {
// 只有开启拾取才需要 encode // 只有开启拾取才需要 encode
const { id } = feature; const { id } = feature;
return enablePicking && layer.isVisible() return enablePicking ? encodePickingColor(id as number) : [0, 0, 0];
? encodePickingColor(id as number)
: [0, 0, 0];
}, },
}, },
}); });

View File

@ -48,6 +48,9 @@ export default class LineDemo extends React.Component {
opacity: 1.0, opacity: 1.0,
}); });
lineLayer.on('click',(e)=> {
console.log(e);
})
scene.addLayer(lineLayer); scene.addLayer(lineLayer);
this.scene = scene; this.scene = scene;
} }