1

is there a way to make ol.interaction.Translate only fires only on shift + click it's really hard to edit a layer when you have Translate and Modify together.

this is my code

var selectInteraction = new ol.interaction.Select({
        condition: ol.events.condition.singleClick,
        //toggleCondition: ol.events.condition.shiftKeyOnly,
        layers: function (layer) {
            return layer.get('id') == 'redline';
        }
    });

    var modify = new ol.interaction.Modify({
        features: selectInteraction.getFeatures()
    });

    var Translate = new ol.interaction.Translate({
        features: selectInteraction.getFeatures()
    });

    map.getInteractions().extend([selectInteraction, modify, Translate]);

    selected_features = selectInteraction.getFeatures();

1 Answer 1

2

Just had the same problem while using translate and modify at the same time. I solved it with changing the order how the interactions are added to the map. Be sure to add the Translate first:

map.getInteractions().extend([selectInteraction, Translate, modify]);
1
  • Awesome answer. Worked great! Commented Jun 18, 2020 at 22:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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