I have a GIS API that uses the OpenLayers 2.13 measure and drawFeature controls. But let's just talk about the measure control, because the issues are certainly connected.

As I show in this CodePen, the measure control is supposed to show the immediate measures, i.e., print them on mouse move.

measureControl = new OpenLayers.Control.Measure(OpenLayers.Handler.Path, measureControlOptions);


measureControl.events.register('measure', measureControl, function(e) {

measureControl.events.register('measurepartial', measureControl, function(e) {

Of course, when I use this example in a touch device, I can't use the onmousemove event. Instead, the behaviour is like this:

  • 1st tap to start measuring
  • 2nd tap to stop measuring

It shows the desired length, but I am not able to perform an accurate measurement because I want to see the measures as I move my finger on the touch screen.

I am not very familiar with touch events, so I apologize if this is a stupid question. but is there an easy way to mimic the mouse behaviour on the touch device?

The desired behaviour is something like:

  • tap down --> starts measuring
  • tap move (without lifting the finger) --> keeps measuring and show the new measurement on each move
  • tap up --> stops the measurement

1 Answer 1


I guess you have to listen to the touchmove event but havent tested this before.

If it does not have to be measuring by touchmove you could habe a look at this example with an optimized measure-control for mobile devices.


enter image description here

UPDATE1: just gave it a try and it works. You can take the event-pixel-value of the touchmove event and use it in combination with map.getLonLatFromLayerPx(e.xy) to get a new vertex point for the line.

Here you can find two working examples:



(with 5px shift so you can see the end of the measuring line)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.