Skip to content

Instantly share code, notes, and snippets.

@lydonchandra
Created December 7, 2012 02:01
Show Gist options
  • Save lydonchandra/4230133 to your computer and use it in GitHub Desktop.
Save lydonchandra/4230133 to your computer and use it in GitHub Desktop.
OpenLayers Delete Feature Control Using Box Selection(inherits from OpenLayers.Control.SelectFeature)
var olDeleteControl = new OpenLayers.Control.SelectFeature( layerToDrawOn, {
clickout: false, toggle: false,
multiple: true, hover: false,
toggleKey: "ctrlKey", // ctrl key removes from selection
multipleKey: "shiftKey", // shift key adds to selection
box: true
});
olDeleteControl.events.on({
'boxselectionend': function(layers){
try {
layers.layers[0].removeFeatures(layers.layers[0].selectedFeatures);
}
catch(err) {
alert('Error deleting features.')
}
}
});
openlayersMap.addControl(olDeleteControl );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment