如何在绘制结束时在OpenLayers3中获取多边形的坐标 [英] How to get the coordinates of a polygon in OpenLayers3 on draw end

查看:652
本文介绍了如何在绘制结束时在OpenLayers3中获取多边形的坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在地图上添加点击处理程序,但是不确定如何判断多边形何时完成绘制. 是否有一个简单的函数可以在绘制端获取多边形坐标?

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 ?

推荐答案

您可能可以改写 https://stackoverflow.com/a /24835176/228885 供您使用.如另一个答案中所述,feature.once('change', ...)可能是另一种方法.我希望在这种情况下,您将从传递给处理程序的功能中选择最后一个元素.然后,您可以从中提取坐标,然后离开.

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;聆听特征的addchange,提取坐标.

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

这篇关于如何在绘制结束时在OpenLayers3中获取多边形的坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆