I have an SVG rendered on a page. I am trying to find all the elements present at a specific coordinate, like (150, 300).
The coordinates are generated by the user clicking on the SVG. I achieved this by adding a callback to each element in the SVG which maps the cursor location to the SVG coordinate with the following code:
const pt = svg.createSVGPoint()
pt.x = event.clientX
pt.y = event.clientY
// The cursor point, translated into svg coordinates
const {x, y} = pt.matrixTransform(svg_ref.current.getScreenCTM().inverse())
Given a coordinate how can I find the corresponding element?