Could you please advise if there is a more elegant and efficient way to get all WebGLLayer features at a click point that can solve this problem?
\nThank you for your attention, with great respect for the work of the developers and the community,
\nGreg Baranov
","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"To get a more accurate array of features at a certain coordinate you might want to use the method of the source you're using, e.g.: https://openlayers.org/en/latest/apidoc/module-ol_source_Vector-VectorSource.html#getFeaturesInExtent
","upvoteCount":1,"url":"https://github.com/openlayers/openlayers/discussions/16289#discussioncomment-10940291"}}}-
Hello, esteemed developers and OpenLayers community members! I’ve encountered an issue when trying to get all the WebGLLayer features at a click point, and I’ve spent quite a bit of time searching for a solution. However, I haven’t been able to find a built-in function in OpenLayers that solves this problem. As mentioned in many other tickets, the getFeaturesAtPixel function of the Map object returns only the topmost feature of the layer. From my experiments with the getFeaturesAtCoordinate function of the VectorSource object, I’ve found that it works well with polygons but not at all with geometries of type MultiLineString, LineString, or Point. Based on the code of the function, I assume it might work with these geometries if the coordinates of their centers are provided. I implemented a workaround to get the features using the getFeaturesAtPixel function, but I’m not satisfied with it as it feels cumbersome and not quite the right approach.
Could you please advise if there is a more elegant and efficient way to get all WebGLLayer features at a click point that can solve this problem? Thank you for your attention, with great respect for the work of the developers and the community, Greg Baranov |
Beta Was this translation helpful? Give feedback.
-
To get a more accurate array of features at a certain coordinate you might want to use the method of the source you're using, e.g.: https://openlayers.org/en/latest/apidoc/module-ol_source_Vector-VectorSource.html#getFeaturesInExtent |
Beta Was this translation helpful? Give feedback.
To get a more accurate array of features at a certain coordinate you might want to use the method of the source you're using, e.g.: https://openlayers.org/en/latest/apidoc/module-ol_source_Vector-VectorSource.html#getFeaturesInExtent