New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add hit detection support to WebGL vector layer #15120
Conversation
a221e3d
to
6e3312b
Compare
📦 Preview the website for this branch here: https://deploy-preview-15120--ol-site.netlify.app/. |
a8762a4
to
73579c5
Compare
73579c5
to
b0bde13
Compare
8c84260
to
f7b964d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also for firefox another workaround could be:
--- a/src/ol/render/webgl/VectorStyleRenderer.js
+++ b/src/ol/render/webgl/VectorStyleRenderer.js
@@ -504,6 +504,9 @@ class VectorStyleRenderer {
frameState,
preRenderCallback
) {
+ if (indicesBuffer.getArray().length === 0) {
+ return;
+ }
this.helper_.useProgram(program, frameState);
this.helper_.bindBuffer(verticesBuffer);
this.helper_.bindBuffer(indicesBuffer);
Here we're simply skipping rendering if no primitives are found in the buffer. This way we don't add complexity to the ShaderBuilder API.
This will be transformed to a unique color per feature by the renderer.
f7b964d
to
8cad922
Compare
Thanks, this looks like the proper thing to do. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks perfect now, thanks a lot!!
@gberaudo - sorry to be the bearer of bad news, but I'm not seeing any feature info displayed on this example https://deploy-preview-15120--ol-site.netlify.app/en/latest/examples/webgl-vector-layer.html on Chrome 116 or Safari 16.4 on a Mac (macOS 13, M1 chip). Has anybody else seen it working on a Mac? |
Unfortunately I'm getting the same results as @tschaub . |
Could reproduce as well on iOS systems only, no errors in the console. The hit detection render target looks completely empty. I suspect this line to make things behave inconsistently:
Here the |
Add hit detection to the WebGL vector layer renderer.
This is similar to the points layer:
forEachFeatureAtCoordinate
method.