Is it possible to determine if a GeoJSON point is inside a GeoJSON polygon using JavasScript?

扶醉桌前 提交于 2019-11-30 08:34:38

Seems like d3 has you covered: https://github.com/d3/d3-geo#geoContains

d3.geoContains(object, point)

Returns true if and only if the specified GeoJSON object contains the specified point, or false if the object does not contain the point. The point must be specified as a two-element array [longitude, latitude] in degrees. For Point and MultiPoint geometries, an exact test is used; for a Sphere, true is always returned; for other geometries, an epsilon threshold is applied.

Expanding the @thedude answer's you can also use geojson-lookup if you need to do this check more than once on a given GeoJSON.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!