[OpenLayers-Users] Problems when deactivating custom control
Eric Lemoine
eric.c2c at gmail.com
Tue May 13 16:28:01 EDT 2008
On Tue, May 13, 2008 at 10:15 PM, Zer <hcan at hotmail.com> wrote:
>
> Hi all,
Hello
> I have made a custom control that gets the length of a line feature. I then
> show this length in a div. When the control gets deactivated, I want the div
> to be cleared. What happens is that the div gets cleared but the control
> does not get deactivated in the panel. Am I missing something here???
>
> mt = new OpenLayers.Control.DrawFeature(vLayer, OpenLayers.Handler.Path,
> { featureAdded: ShowDistance,
> handlerOptions: {'freehand': true},
> displayClass: 'MeasureTool',
> deactivate: function() {clearDistance();},
> });
>
> If I remove this line "deactivate: function() {clearDistance();" the control
> gets deactivated in the panel, but how do I then get the div cleard?
>
> I also want to clear the div when a new line is drawn. Is there a way to
> capture an event for this?
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
More information about the Users
mailing list