1

I have select and modify interaction instantiated. Also I have event onChange binded to selected feature.

select.getFeatures().getArray()[0].on('change',function (){
    sources.verteksi.clear()
    koordinate=select.getFeatures().getArray()[0].getGeometry().getCoordinates()
    koordinate.forEach(function(koord){
        koord.forEach(function(ko){
            sources.verteksi.addFeature(new ol.Feature({geometry:new ol.geom.Point(ko,'XY')}))
        })  
    })  
})

On the other hand I have layer which I modify and select :

arkod_editing=new ol.layer.Vector({
    source: sources.arkod_editing,
    style: new ol.style.Style({
        stroke: new ol.style.Stroke({
            color: 'red',
            width: 2
        }),
        fill: new ol.style.Fill({
            color:'rgb(190,270,80,0.5)'
        }),

        })
  }) 

The problem is when I modify feature from arkod_editing layer I send it to transactional WFS but before I am setting id of feature which triggers onChange event like feature is coming from select layer. Is it possible to outflank the bond beetween select and modified feature in layer arkod_editing?

1

You could use the modify start and end events to set a flag which could be tested in the feature change events

    var modifying = false;
    modify.on('modifystart', function(){ modifying = true; });
    modify.on('modifyend', function(){ modifying = false; });

Modify causes feature change events to fire repeatedly while the interaction is active. It would be more efficient to use the modify end event to process the changed feature.

  • Yes I know about those events , but that is not what I am asking for here. The question is how to lose bond between modified feature and select , because once I do modifications on some layer feature, newly created feature behaves like It is part of Select layer(which comes with select interaction), so it triggers events that are binded to select. – Goran Jul 8 at 11:36
  • In select.getFeatures().getArray()[0].on('change', ... ) the change event is bound to a feature which happens to be selected when the listener is first set, but events will continue to fire for that feature regardless of whether it is still selected or the bonding between select and modify. – Mike Jul 8 at 12:05

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.