In my react application
, I've drawn a polygon
by using some points and then I'm trying to find out if mouse current location is inside the polygon or not. I'm using d3.polygonContains and passing it points array with current location points but it always returns false, although points are inside polygon.
here is an example;
let points = [
[ 42.34624, -71.06024 ],
[ 42.33558, -71.06616 ],
[ 42.32632, -71.05835 ],
[ 42.32987, -71.05428 ],
[ 42.34732, -71.05432 ],
[ 42.34618, -71.05973 ],
[ 42.34624, -71.06024 ]
];
let testPoint = [
[42.33288, -71.05835]
];
alert(d3.polygonContains(points, testPoint));
alert(d3.polygonContains(points, (42.33288, -71.05835)));
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/5.7.0/d3.min.js"></script>
Can anybody tell me what I'm doing wrong here??