[OpenLayers-Users] How to modify control behavior with shift or ctrl or other keys?

Stephen Woodbridge woodbri at swoodbridge.com
Tue Mar 4 17:24:36 EST 2008


Hi all,

I'm working with svn and a modify feature control.
http://imaptools.com/~woodbri/edit/index26.php?extent=-129,19+-60,60

I would like to be able to change the behavior of the modify feature 
control to

1) disable ROTATE if the shift key is held down
2) on ctrl-click selection of a feature put it in RESHAPE mode

             var modifyPolygon = new OpenLayers.Control.ModifyFeature(
                 wfs, modifyOptions);
             //modifyPolygon.mode = 
OpenLayers.Control.ModifyFeature.RESHAPE;
             modifyPolygon.mode  = OpenLayers.Control.ModifyFeature.RESIZE;
             modifyPolygon.mode |= OpenLayers.Control.ModifyFeature.ROTATE;
             modifyPolygon.mode |= OpenLayers.Control.ModifyFeature.DRAG;
             modifyPolygon.mode &= 
~OpenLayers.Control.ModifyFeature.RESHAPE;

             modifyPolygon.featureAdded = function(feature) {
                 feature.layer.eraseFeatures([feature]);
                 feature.geometry = new OpenLayers.Geometry.MultiPolygon(
                     feature.geometry
                 );
                 //feature.style.strokeColor = "#ff0000";
                 feature.fid = feature.attributes.guid;
                 feature.attributes.fid = feature.attributes.guid;
                 feature.state = OpenLayers.State.UPDATE;
                 feature.layer.drawFeature(feature);
             };

So for 1) I think I need to add a handler that watches keyboard events 
to the control and on shift keydown remove 
OpenLayers.Control.ModifyFeature.ROTATE and then on keyup reapply it.

What is the best way to do this in OL?

for 2) how do I detect ctrl-click or shift-click on a feature select? 
What would be the best way to do this?

Thanks,
   -Steve W




More information about the Users mailing list