Skip to main content
edited tags
Link
nagytech
  • 3.8k
  • 19
  • 37
added 95 characters in body
Source Link
Dennis Bauszus
  • 2.3k
  • 3
  • 21
  • 32

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.

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/

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.

Source Link
Dennis Bauszus
  • 2.3k
  • 3
  • 21
  • 32

OpenLayers 3.5.0, clear highlighted feature after removing feature from source

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/