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 is as follows:

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

It is possible to switch from hand. But there is nothing to completely deactivate it. Every time I press shift, free hand mode is used.

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

+5
source share
1 answer

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

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

+7
source

All Articles