Hi all,<br><br>I have a Vector layer being initialized with a default style. I am then adding new vector features (Points) dynamically via Ajax calls and GeoJSON data.<br><br>Anyway, if I try to apply a non-default style to a Point dynamically using something similar to this code:<br>
<br>{{{<br>        /* init code */<br><br>        var defaultStyle = new OpenLayers.Style({<br>            pointRadius: &quot;${radius}&quot;,<br>            fillColor: &quot;#00ddff&quot;,<br>            fillOpacity: 1,<br>
            strokeColor: &quot;#008899&quot;,<br>            strokeWidth: 1,<br>            strokeOpacity: 1,<br>        }, {<br>            context: {<br>                radius: function(feature) {<br>                    var pix = 3;<br>
                    if (feature.cluster) {<br>                        pix = Math.min(feature.attributes.count, 5);<br>                    }<br>                    return pix;<br>                },<br>                width: function(feature) {<br>
                    return (feature.cluster) ? 3 : 1;<br>                }<br>            }<br>        })<br><br>       var layer = new OpenLayers.Layer.Vector(&quot;the name&quot;, {<br>                strategies: strat, // Cluster, Fixed<br>
                protocol: new OpenLayers.Protocol.HTTP({<br>                    url: data.url, // the URL<br>                    format: frmt // GeoJSON<br>                }),<br>                projection: new OpenLayers.Projection(&#39;EPSG:4326&#39;),<br>
                styleMap: new OpenLayers.StyleMap({<br>                    &quot;default&quot;: defaultStyle,<br>                    &quot;select&quot;: {<br>                        fillColor: &quot;#8aeeef&quot;,<br>                        strokeColor: &quot;#32a8a9&quot;<br>
                    }<br>                })<br>            })<br><br>       map.addLayer(layer); // ==&gt; map.layers[2]<br><br>        /* problem code */<br><br>       // map.layers[2].features[0] is the first point (in thousands of points) in this layer<br>
       map.layers[2].features[0].style = new OpenLayers.Style({<br>                pointRadius: &quot;${radius}&quot;,<br>                fillColor: &quot;#7766ff&quot;,<br>                fillOpacity: 1,<br>                strokeColor: &quot;#2222ff&quot;,<br>
                strokeWidth: 1,<br>                strokeOpacity: 1<br>            }, {<br>                context: {<br>                    radius: function(feature) {<br>                        var pix = 3;<br>                        if (feature.cluster) {<br>
                            pix = Math.min(feature.attributes.count, 5);<br>                        }<br>                        return pix;<br>                    },<br>                    width: function(feature) {<br>                        return (feature.cluster) ? 3 : 1;<br>
                    }<br>                }<br>            });<br>}}}<br><br>the Point in this layer disappears. What I want to do is change the style to anything I want.<br><br>I must be missing something or misunderstanding how styles are applied in OpenLayers. Thanks in advance for any and all help. I really appreciate it.<br clear="all">
<br>-- <br>Jonathan Sawyer<br>Geographic Information Network of Alaska (GINA)<br>University of Alaska Fairbanks<br>