[GIS] OpenLayers 3 – how to redraw a single feature

openlayersrendering

I would like to be able to trigger re-rendering of a single feature after a user has clicked on it. (I can catch the click and update the metadata that feeds the styling function, but I am then forced to re-render the entire layer to get the updated styling to show:

kmlSource.dispatchChangeEvent();

Performance is horrible redrawing a an entire large layer when just one feature's style has changed. Is there any way I can redraw just one feature?

Even if the rendering wasn't perfect (for example the redrawn feature was on top) that would be fine.

I note this older question on the previous version of openlayers, but I can't find anything addressing the issue on OpenLayers 3.

Best Answer

From the sounds of things I'd suggest trying the changed() function on the feature after updating the styling. This seems to work when I updated the scale of the style for a feature. See the feature changed documentation