[OpenLayers-Users] Sub classing ModfifyFeature control changing delete key

Dave Potts dave.potts at pinan.co.uk
Tue Oct 22 08:10:34 PDT 2013


Hi List,

I trying to change the design of a openlayers gui.

If I used ModifyFeature to allowed the editing of a polygon on a layer, 
if you press the delete key from the keyboard  it deletes a node.

I am trying to change it so that its possible to to have a button on 
javascript dialog to do the same.

I assume it would be case of subclassing the ModifiyFeature control, 
adding a click handler and faking a keypress event and calling 
handleKeypress

So far my solution is to say something like this,  I had assumed that 
the clickHandler would be called, but it seems to be ignored. I am 
calling this as a control argument in the clickHandler set up, since 
FOOModifyFeature is a Control, it get invoked, not nothing ever happens.

Does anybody have an idea what I am doing wrong?

FOOModifyFeature=OpenLayers.Class(OpenLayers.Control.ModifyFeature, {

          //initialize:function(layer,options){
          initialize:function(options){
                 console.log("3:ZZZZZZZZZZZZZZZZZZZZZZZZZZXXXX: mod 
feature "+options);
OpenLayers.Control.ModifyFeature.prototype.initialize.apply(this,[options]);

                 console.log("Code setup");
                 var  handlerOptions={
                     'single': true,
                     'double': false,
                     'pixelTolerance': 0,
                     'stopSingle': false,
                     'stopDouble': false
                 };
                 // need to include an extra handler to get a click event.
                 var clickHandler= new OpenLayers.Handler.Click(
                         this,{'click':this.onClick},handlerOptions);

         },
         onClick:function(evt){
                 console.log("E "+ evt.xy);
         },
         CLASS_NAME: "FOOModifyFeature"

});



More information about the Users mailing list