0

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.

  • The question you refer to on OpenLayers 2. Is your question about OpenLayers 2 or OpenLayers 3? – erilem Dec 6 '14 at 17:40
1

Your use case should be covered by ol.interaction.Select. For drawing the selected feature with a different style, ol.interaction.Select creates an ol.FeatureOverlay with your alternate style and adds your feature to that overlay. To hide the original feature while displaying your feature on the overlay, it uses the internal ol.Map#skipFeature() method to skip the selected feature when replaying the render sequence on the original layer.

  • ahocevar, ol.Map#skipFeature isn't currently part of the API. But it should probably be. – erilem Dec 8 '14 at 10:02
  • erilem, I'll refine my answer. I am not so sure that ol.Map#skipFeature should be part of the API. I just thought it was. – ahocevar Dec 9 '14 at 13:02
1

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

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.