<div dir="ltr">After drawing point features in a vector layer, when a single style attribute is changed for a point it appears that its default values are being overwritten. Specifically, if I only change the fillColor of a point its default values are erased or changed. Example:<br>
<br>var myFeatures = new OpenLayers.Layer.Vector(&quot;My Features&quot;);<br><br>var testPt1 = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-118, 35));<br>var testPt2 = new OpenLayers.Feature.Vector(new OpenLayers.Geometry.Point(-117, 35));<br>
myFeatures.addFeatures([testPt1,testPt2]);<br><br>testPt2.style = {fillColor: &#39;red&#39;};<br>myFeatures.drawFeature(testPt2);<br><br>Firebug output:<br><div class="nodeChildBox"><div class="nodeBox emptyNodeBox repIgnore">
<div class="nodeLabel"><span class="nodeLabelBox repTarget">&lt;<span class="nodeTag">circle</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">id</span>=&quot;<span class="nodeValue editable">OpenLayers.Geometry.Point_145</span>&quot;</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">cx</span>=&quot;<span class="nodeValue editable">350.12444444444463</span>&quot;</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">cy</span>=&quot;<span class="nodeValue editable">341.0222222222221</span>&quot;</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">r</span>=&quot;<span class="nodeValue editable">0</span>&quot;</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">fill</span>=&quot;<span class="nodeValue editable">red</span>&quot;</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">fill-opacity</span>=&quot;<span class="nodeValue editable">1</span>&quot;</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">stroke</span>=&quot;<span class="nodeValue editable">none</span>&quot;</span><span class="nodeBracket editable insertBefore">/&gt;</span></span></div>
</div><div class="nodeBox emptyNodeBox repIgnore"><div class="nodeLabel"><span class="nodeLabelBox repTarget">&lt;<span class="nodeTag">circle</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">id</span>=&quot;<span class="nodeValue editable">OpenLayers.Geometry.Point_143</span>&quot;</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">cx</span>=&quot;<span class="nodeValue editable">304.6133333333337</span>&quot;</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">cy</span>=&quot;<span class="nodeValue editable">341.0222222222221</span>&quot;</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">r</span>=&quot;<span class="nodeValue editable">6</span>&quot;</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">fill</span>=&quot;<span class="nodeValue editable">#ee9900</span>&quot;</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">fill-opacity</span>=&quot;<span class="nodeValue editable">0.4</span>&quot;</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">stroke</span>=&quot;<span class="nodeValue editable">#ee9900</span>&quot;</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">stroke-opacity</span>=&quot;<span class="nodeValue editable">1</span>&quot;</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">stroke-width</span>=&quot;<span class="nodeValue editable">1</span>&quot;</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">stroke-linecap</span>=&quot;<span class="nodeValue editable">round</span>&quot;</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">pointer-events</span>=&quot;<span class="nodeValue editable">visiblePainted</span>&quot;</span><span class="nodeAttr editGroup">&nbsp;<span class="nodeName editable">cursor</span>=&quot;<span class="nodeValue editable"></span>&quot;</span><span class="nodeBracket editable insertBefore">/&gt;<br>
<br>The pointRadius is changed to 0, the fillOpacity is changed to 1, strokeColor is changed to &quot;none&quot;, and other default attributes are gone causing the symbol not to display in the map. Trying:<br><br>myFeatures.drawFeature(testPt2, {fillColor: &#39;red&#39;});<br>
<br>gives two identical points with no attributes changed for the second point. In my actual code I am changing a point&#39;s fillColor dynamically when a user selects it from a list (after the map loading function has completed):<br>
<br>myFeatures.drawFeature(myFeatures.features[key], {fillColor: &#39;red&#39;});<br><br>and like the first example the </span></span><span class="nodeLabelBox repTarget"><span class="nodeBracket editable insertBefore">pointRadius is changed to 0, the fillOpacity is changed to 1, strokeColor is changed to &quot;none&quot;, but unlike the first example other default values remain as is.</span></span><br>
<span class="nodeLabelBox repTarget"><span class="nodeBracket editable insertBefore"><br>These are three very different outcomes, and the behavior I expected was that only attributes I explicitly changed would change while all other default/set values would remain unchanged. If this is a bad assumption on my part or there is some documentation I&#39;ve missed please let me know, otherwise this may be a bug.<br>
<br>Thanks,<br>Ian<br></span></span></div></div></div></div>