Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenLayers: How to disable the shift key or freehand mode for DrawFeature

I would like to disable the shift key or freehand mode for the DrawFeature Control. A typical code looks like that:

var drawOptions = {handlerOptions: {freehand: true}};
drawFeatureControl = new OpenLayers.Control.DrawFeature(lineLayer, OpenLayers.Handler.Path, drawOptions);
map.addControl(drawFeatureControl);

There is the option to switch freehand on. But there is nothing to totally deactivate it. Every time I hit shift the freehand mode is used.

In my use case I would like to use the shift key for another behaviour.

like image 292
strangeoptics Avatar asked Jun 05 '12 11:06

strangeoptics


1 Answers

See http://dev.openlayers.org/docs/files/OpenLayers/Handler/Path-js.html#OpenLayers.Handler.Path.freehandToggle

drawFeatureControl.handler.freehandToggle = null; does the trick. Reset it to 'shiftKey' if you want to re-enable it.

like image 88
tonio Avatar answered Sep 18 '22 08:09

tonio