How to get the coordinates of a polygon in OpenLayers3 on draw end

半世苍凉 提交于 2019-12-11 05:17:17

问题


I have tried to add a click handler to the map, but am not sure how to tell when the polygon has finished drawing. Is there a simple function to get the polygon coordinates on draw end ?


回答1:


You can probably adapt https://stackoverflow.com/a/24835176/228885 for your purposes. As mentioned in another answer feature.once('change', ...) might be another way to go. I expect in that case you would pick the last element from the feature passed to the handler. Then you would extract the coordinates out of it and off you go.

TLDR; Listen add or change of features, extract coordinate.



来源:https://stackoverflow.com/questions/24018893/how-to-get-the-coordinates-of-a-polygon-in-openlayers3-on-draw-end

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