1

I'm using OpenLayers-3.8.2 for developing a GIS application. Users draw some features and can modify all existing features on the map. They can delete features. I can delete feature as follow:

  1. user click some features
  2. User click on a button and then: layer.getSource().removeFeature(feature)

Now I want the user to be able to remove features with del key.

What do I implement it?

1

This way:

var deleteFeature = function(evt){
    if(evt.keyCode == 46){ //delete key pressed
        //delete feature

    }
};
document.addEventListener('keydown', deleteFeature, false);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.