[OpenLayers-Users] measure / measurepartial

Andreas Hocevar ahocevar at opengeo.org
Fri Sep 18 03:47:43 EDT 2009


Hey-

Richard Greenwood wrote:
> I'm trying to make sense of measure versus measurepartial event types
> in OL 2.8. Mouse moves and single clicks both report an event type of
> "measurepartial". Only a double click report a "measure" event type. I
> would like to distinguish between an mouse move (rubber band) and a
> single click (which creates a new vertex in the line string). The only
> way I have figured out so far to do this is to monitor the length of
> event.geometry.components but it seems like there should be a better
> way, which possibly I am missing.
>   

The Measure control does not register a callback for the handler's
modify event, which means that you normally receive a measurepartial
event on a single click and a measure event on double click. If you also
receive measurepartial on mouse move, then you have configured your
control with a callback on the handler's modify event, probably like this:

var control = new OpenLayers.Control.Measure(/* your config here */);
control.handler.callbacks.modify = function(point, feature) {
    control.measurePartial(point, feature.geometry);
};

So the only thing you need to do is change this modify callback to not
call control.measurePartial, but instead do what you want to do when the
mouse moves.

Regards,
Andreas.

> Specifically what I am trying to do is display the angle and length of
> the vector as it is "rubber banded" by mouse moves, and also a running
> total distance between single clicked vertices.
>
> Thanks,
> Rich
>
>   


-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.




More information about the Users mailing list