简体   繁体   English

单击事件处理Openlayers 3中的绘图功能

[英]Click event handling for draw features in Openlayers 3`

I have implemented the following example from the Openlayers 3 library where you can measure lines and areas. 我已经从Openlayers 3库中实现了以下示例,您可以在其中测量线和面。

http://openlayers.org/en/latest/examples/measure.html http://openlayers.org/en/latest/examples/measure.html

Specifically for areas, to complete the shape you can either double click at the last vertex you want to draw, or single click back at the start of the shape when the cursor snaps to the original point. 特别是对于区域,要完成形状,您可以双击要绘制的最后一个顶点,或者在光标捕捉到原始点时在形状的开头单击以单击。

I have an issue whereby many users are taking their cursor back to the original point and it is snapping, but they are double clicking thinking therefore completing the original shape and inadvertently starting a new one. 我遇到了一个问题,许多用户将光标移回原始点,但仍在跳动,但是他们是双击思维,因此完成了原始形状并无意间开始了新的形状。

How am I able to code this example so that if a double click occurs at the original point, then the shape is completed but a new shape not started? 我如何编写此示例的代码,以便如果在原始点上双击了该图形,则该图形完成了,但新的图形没有开始?

Thanks 谢谢

You can set property snapTolerance into 1, it should help: 您可以将属性snapTolerance设置为1,这应该会有所帮助:

new ol.interaction.Draw( { snapTolerance: 1, ...

You still can finish shape with single click, but you have to click exactly in the first point. 您仍然可以单击完成形状,但是您必须在第一点上完全单击。

I set snapTolerance for myself some time before and people are happy now :). 我之前为自己设置了snapTolerance,现在人们很高兴:)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM