From 9c7d9e902c4be5d1ee4e56d573fe52567ef06300 Mon Sep 17 00:00:00 2001 From: thinkinggis Date: Fri, 7 Feb 2020 22:12:56 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20layer=20=E6=8B=BE=E5=8F=96=20fix=20#191?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../renderer/passes/PixelPickingPass.ts | 22 +++++++++---------- .../layers/src/plugins/PixelPickingPlugin.ts | 4 +--- stories/Layers/components/Line.tsx | 3 +++ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/packages/core/src/services/renderer/passes/PixelPickingPass.ts b/packages/core/src/services/renderer/passes/PixelPickingPass.ts index 699258ed4b..3227532a0a 100644 --- a/packages/core/src/services/renderer/passes/PixelPickingPass.ts +++ b/packages/core/src/services/renderer/passes/PixelPickingPass.ts @@ -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: { diff --git a/packages/layers/src/plugins/PixelPickingPlugin.ts b/packages/layers/src/plugins/PixelPickingPlugin.ts index 2880f1629f..31b73ccaee 100644 --- a/packages/layers/src/plugins/PixelPickingPlugin.ts +++ b/packages/layers/src/plugins/PixelPickingPlugin.ts @@ -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]; }, }, }); diff --git a/stories/Layers/components/Line.tsx b/stories/Layers/components/Line.tsx index bb21ece948..ae44add630 100644 --- a/stories/Layers/components/Line.tsx +++ b/stories/Layers/components/Line.tsx @@ -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; }