Skip to content
Advertisement

Recognize point(x,y) is inside svg path or outside

I have closed SVG path that is the province of the country.

How to recognize point(x,y) is inside SVG path or outside by javascript?

Advertisement

Answer

Call document.elementFromPoint. If the position is in the path then it will return that element. If the path is not filled then you may need to adjust the pointer-events property so that it works properly.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement