If you want to set a symbolizer on a feature directly, don't give it an OpenLayers.Style instance, but a symbolizer object literal, like so:
layer.features[1].style.fillColor = "#DFDFFF"; layer.redraw(); Style instances are for use in StyleMap. And yes, this is awkward, and if there wasn't KML which sets styles on features directly, feature.style would be deprecated. The modern way to do what you want to achieve here would be a Style with a FeatureID filter in the layer's StyleMap. Andreas. On Mon, Nov 21, 2011 at 3:19 AM, Denis Rykov <[email protected]> wrote: > Could anyone explain one confusing things. > I want to change style of particular one of many features in the layer. > > Why this syntax works: > > layer.features[1].style = new OpenLayers.Style(); > layer.features[1].style.fillColor = "#DFDFFF"; > layer.redraw(); > > But this no give expected result: > > layer.features[1].style = new OpenLayers.Style({fillColor: "#DFDFFF"}); > layer.redraw(); > > Thanks! > > > _______________________________________________ > Users mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/openlayers-users > > -- Andreas Hocevar OpenGeo - http://opengeo.org/ Expert service straight from the developers. _______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
