ol.interaction.TouchDraw is an interaction to use on touch devices.
The pointer is deferred to the center of the viewport and a target is drawn to materialize this point.
So drawing consists in moving the map under the target thus the sketch is not masked by the finger when moving.
-
Tapping on the device will create a new point and a double tap finish the drawing. You can disable the behavior when setting the tap option to false.
It derives from an
ol.interaction.CenterTouch that handle the centering:
-
It modifies map browser event coordinate and pixel properties to force pointer on the center of the viewport to any interaction that them.
-
The coordinate modification is deported on the top of the interaction queue and other can be used after then (a snap interaction is used in this example).
The example uses an
ol.control.Bar with
ol.control.Toggle to control the interaction.