How can I determine whether a 2D Point is within a Polygon?

前端 未结 30 2168
醉梦人生
醉梦人生 2020-11-21 05:06

I\'m trying to create a fast 2D point inside polygon algorithm, for use in hit-testing (e.g. Polygon.contains(p:Point)). Suggestions for effective tech

30条回答
  •  误落风尘
    2020-11-21 06:05

    If you are looking for a java-script library there's a javascript google maps v3 extension for the Polygon class to detect whether or not a point resides within it.

    var polygon = new google.maps.Polygon([], "#000000", 1, 1, "#336699", 0.3);
    var isWithinPolygon = polygon.containsLatLng(40, -90);
    

    Google Extention Github

提交回复
热议问题