识别点(x,y)在svg路径之内或之外 [英] Recognize point(x,y) is inside svg path or outside

查看:53
本文介绍了识别点(x,y)在svg路径之内或之外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经关闭了该国的省份SVG路径.

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

如何通过JavaScript识别点(x,y)在SVG路径之内还是之外?

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

推荐答案

调用文档. elementFromPoint .如果位置在路径中,则它将返回该元素.如果未填写路径,则可能需要调整指针事件属性,以使其正常工作.

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.

这篇关于识别点(x,y)在svg路径之内或之外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆