I've created a bunch of Feature.Vectors from Point objects and assigned them a Style. Now I want to dynamically change the appearance of one of the features in real time; e.g., change it from red to blue. (I am NOT hovering over the feature.) I've tried changing its Style, then doing refresh() on the layer, or redraw(), etc, and either nothing happens or the feature disappears. Any suggestions? Thanks.

  • have you save this problem already? – user25495 Jan 6 '14 at 14:40

Redraw method should solve your problem, see my little example: OpenLayers: modifying feature style

UPD: I've modified my example a little bit: OpenLayers: modifying one feature style

  • Thanks however this appears to change the appearance of the entire layer, rather than that of a particular one of many features in the layer, right? – bethesdaboys Nov 17 '11 at 14:48
  • Could you look at new example, is it what you need? – drnextgis Nov 21 '11 at 2:08
  • @drnextgis : Nice example. +1 – simo Nov 21 '11 at 14:23

I agree with @drnextgis that redraw will do (+1 for nice sample). Though in your situation, since you want to just redraw a single feature, I would use feature.layer.drawFeature(feature); which is presented in the following sample here.

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.