Hi Jim,

Several questions first :
 - Are you using a vector layer with a strategy, a protocol and a KML format
?
 - Are you extracting styles from the KML file (extractStyles property set
to true in the KML format) ?
 - Did you attempt to replace the styles using a StyleMap at the layer level
?
 - Did you refresh by calling redraw on the layer ?

One thing to know is that extracting styles from a KML file will set a
"style" property at the feature level. Applying a "stylemap" at the layer
level will no take precedence.

For example, if you try the following in the kml-layer.html example, only
one feature will change ; the one that has no predefined style :
------------------
var layer = map.layers[1];
layer.styleMap = new OpenLayers.StyleMap({'default': {fillColor: '#FF0000',
strokeColor: '#0000FF', strokeWidth: 4}});
layer.redraw();
------------------

So if you want to change the style of features in case you extracted styles
from the KML file, you will have to change the styles for each one :
------------------
layer.features[2].style.strokeColor = '#00ff00';
layer.redraw();
------------------

Regards,
Pierre


On Fri, Dec 10, 2010 at 12:11 AM, Jim Williams <[email protected]>wrote:

>
> Hello,
> I am loading a fairly large KML file via OpenLayers. Based on user input,
> the styling of the polygons will change. However, I would prefer a method of
> programatically changing the styles of the existing features, rather than
> reloading a new KML file on each change. My attempts to replace the existing
> style with a new style object then doing a refresh don't seem to work. Could
> anyone offer some advice and/or point me in the correct direction?
> Thanks,Jim
>  _______________________________________________
> Users mailing list
> [email protected]
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>



-- 
Pierre GIRAUD
Géomaticien, Analyste

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 93
Mail : [email protected]
http://www.camptocamp.com
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to