Ok<br><br>I finally found a solution (not sure it's the easier solution but it's working in all case<br><br>When declaring StyleMap I add this Rule:<br><br>new OpenLayers.Rule({<br> name : "changestate",<br>
symbolizer: { "Polygon": { display : "none"} },<br> filter: new OpenLayers.Filter.FeatureId({fids : []})<br> })<br><br>
So currently this has no impact, as the list of features id is empty.<br><br>Now, in my changestate function (this function is called when a feature status must be changed : show/hide)<br><br> features = layer.features;<br>
unactivelist = new Array(); // List of feature ids to hide<br> n = 0;<br> for(i=0;i<dtnode.parent.childList.length;i++) { // I am using dynatree (tree with checkbox)<br><br>
// if style is defined (no stylemap associated) normal case, just style.display = "none"<br> if (features[i].style) {<br> if (dtnode.parent.childList[i].isSelected()) <br>
features[i].style.display = "block";<br> else<br> features[i].style.display = "none";<br> } else {<br> if (!dtnode.parent.childList[i].isSelected())// checkbox not active so add to unactive<br>
unactivelist[n++] = features[i].id;<br> }<br> }<br> }<br><br> //Get layer.stylemap.style.rules.filter and change fids to the new list, redraw the layer<br>
style = layer.styleMap.styles["default"];<br> for(j=0;j<style.rules.length;j++)<br> {<br> if (style.rules[j].name == 'changestate')<br>
{<br> style.rules[j].filter.fids = unactivelist;<br> }<br> }<br> <br> }<br> layer.redraw();<br>
<br><br><br><br><div class="gmail_quote">2010/8/4 Thomas PAPIN <span dir="ltr"><<a href="mailto:thomas.papin@gmail.com">thomas.papin@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Hi, it's again me :)<br><br>When I want to hide/show a feature, I just do in a normal case: feature.style.display = "none";<br>This is working great.<br><br>But in the following case it's not working, and I don't have what to do.<br>
<br>- I have a KML with placemark (Point and Polygon)<br>- Each Placemark have attributes like (fontColor,label,labeloffestY)<br>- I used a StyleMap to style the features of this KML<br>like that:<br>var extraMap = new OpenLayers.StyleMap({'default':{<br>
fillOpacity: 1,<br> pointRadius: "${pointSize}",<br> label : "${label}",<br> fontColor: "${fontColor}",<br> fontSize: "${labelSize}px",<br>
....<br><br>GMLlayer = new OpenLayers.Layer.GML(json.files[i].name, json.files[i].kml, <br> {<br> format: OpenLayers.Format.KML, <br>
formatOptions: {<br> extractStyles: true, <br> extractAttributes: true,<br>
maxDepth: 2<br> },<br> styleMap: style<br> });<br>
<br>Then when I tried to do feature.style.display but feature.style is not defined.<br><br>What can I do :-( ?<br>
</blockquote></div><br>