2

I want the user to be able to delete the highlighted feature. This works well, but the feature is not cleared until I move the pointer outside the feature geometry.

I am using the OL 3.5.0 library.

This is the code:

var selectPointerMove_Highlight = new ol.interaction.Select({
  condition: ol.events.condition.pointerMove
  });
map.addInteraction(selectPointerMove_Highlight);

var selectClick_Delete = new ol.interaction.Select({
  condition: ol.events.condition.click
  });
map.addInteraction(selectClick_Delete);

selectClick_Delete.getFeatures().on('change:length', function(e) {
  var feature = e.target.item(0);
  vectorSource.removeFeature(feature);
  selectClick_Delete.getFeatures().clear();
  selectPointerMove_Highlight.getFeatures().clear();
  });

Here is a JSFiddle to show the behaviour. I would expect the highlight to vanish after the clear function is called.

http://jsfiddle.net/goldrydigital/5azhb1o3/

Edit:

I tried a map.renderSync() to force a re-render of the map, but that didn't do it.

1

Take a look at this fiddle.

I've made some modifications, basically I remove the highlight interaction (on removefeature) and put it back on pointermove event.

  • i have tried this as well before. but the behavior is still the same. the highlight only vanishes once the pointer is moved outside of the geometry fence. – Dennis Bauszus May 22 '15 at 18:04
  • Did you see my modified fiddle? The highlight is vanished instantly. – Jonatas Walker May 22 '15 at 18:08
  • actually it did. i looked at the fiddle on chrome first and here the behaviour is the same. on firefox this works. strange. any idea why the behaviour might be different on ff compared to chrome? – Dennis Bauszus May 22 '15 at 18:18
  • I've made it entirely on chrome. Checked also on Opera and FF. OS - Linux (Mint). I suggest you debug on console. – Jonatas Walker May 22 '15 at 18:29

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.