Geofencing feature - Place Map points ,polygon ,Identify point within polygon

寵の児 提交于 2019-12-25 10:16:42

问题


I have two queries regarding Polygon in Open Layers.

1)How can we place some array of points on the OS map?

2)Suppose we want to draw a polygon. How could we know whether the points are inside of the polygon or not. In short if we draw a polygon, we fetch the boundaries: How can we identify whether the points are inside the polygon or not?

Any help would be appreciated as I am a beginner.


回答1:


Welcome to the OpenLayers community!

1) See this example to learn how to add point(s) to a map: http://openlayers.org/en/v3.8.2/examples/icon.html. I strongly suggest you also read the "concepts" tutorial: http://openlayers.org/en/v3.8.2/doc/tutorials/concepts.html

2) A polygon object has the intersectsExtent method, which can be used to see if an extent intersects with an extent. After you have drawn the polygon, you could loop in the array of points and collect each one which extent intersects with the polygon. See the documentation: http://openlayers.org/en/v3.8.2/doc/tutorials/concepts.html

I would separate the points and polygons into 2 layers to keep them separate and more easily loop in the point features.



来源:https://stackoverflow.com/questions/32375716/geofencing-feature-place-map-points-polygon-identify-point-within-polygon

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