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.layer.setCurrentPickId(null);
}
});
if (enableHighlight) {
this.highlightPickedFeature(pickedColors);
}
if (
enableSelect &&
type === 'click' &&
pickedColors?.toString() !== [0, 0, 0, 0].toString()
) {
this.selectFeature(pickedColors);
}
if (enableHighlight) {
this.highlightPickedFeature(pickedColors);
}
if (
enableSelect &&
type === 'click' &&
pickedColors?.toString() !== [0, 0, 0, 0].toString()
) {
this.selectFeature(pickedColors);
}
});
};
private triggerHoverOnLayer(target: {

View File

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

View File

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