[OpenLayers-Users] Problems when deactivating custom control

Eric Lemoine eric.c2c at gmail.com
Tue May 13 17:01:02 EDT 2008


On Tue, May 13, 2008 at 10:46 PM, Zer <hcan at hotmail.com> wrote:
>
>
>
>  Eric Lemoine-3 wrote:
>  >
>  >
>  > How about that:
>  >
>  > mt = new OpenLayers.Control.DrawFeature(vLayer, OpenLayers.Handler.Path, {
>  >     featureAdded: ShowDistance,
>  >     handlerOptions: {'freehand': true},
>  >     displayClass: 'MeasureTool'
>  > });
>  > mt.events.on({
>  >     'deactivate': function() {
>  >         clearDistance();
>  >     }
>  > });
>  >
>  > Cheers,
>  > --
>  > Eric
>
> > _______________________________________________
>  > Users mailing list
>  > Users at openlayers.org
>  > http://openlayers.org/mailman/listinfo/users
>  >
>  >
>
>  Thanks Eric! Works perfectly!
>
>  Is there a way to capture the events when a new line is drawn? Are there any
>  events when the users moves the mouse to draw the line? What I am looking
>  for is a way to clear the text that shows the distance when the users starts
>  to measure a new distance. I would also like to constantly update the
>  distance text, while the user moves the mouse in order to draw the line.

There's no way to achieve this using the draw feature control. What
you can do is implement your own control. In addition to configuring a
'done' callback in the path handler your control would also configure
a 'point' callback. Start from Control/DrawFeature.js and build upon
it.

Cheers,
--
Eric



More information about the Users mailing list