Reputation: 23
I'm trying to add a select interaction for hightlighting the features I drawed like in this example but on my own draws:
http://openlayers.org/en/master/examples/select-features.html
To Hightlight the features I use ol.events.condition.pointerMove
var highlighter = new ol.interaction.Select({
layers: [featureOverlay],
condition: ol.events.condition.pointerMove
});
In my example, when I draw a polygon, start the "Hightlighter" and go on the drawed feature it seems like the selection toggle switch.
I think this code worked on the 3.13.1 version
Here's a Fiddle
Upvotes: 2
Views: 114
Reputation: 14150
You are adding your drawn features to an unmanaged layer (the old ol.FeatureOverlay
) with featureOverlay.setMap(map);
. I'm not sure why you need this and why this flickering but if you change to a managed ol.layer.Vector
then this behavior is gone:
var featureOverlay = new ol.layer.Vector({
source: new ol.source.Vector(),
style: featureStyle
});
map.addLayer(featureOverlay);
var drawPolygon = new ol.interaction.Draw({
source: featureOverlay.getSource(),
type: 'Polygon'
});
http://jsfiddle.net/jonataswalker/p1q7s50k/
Upvotes: 1