<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("My Features");<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: 'red'};<br>myFeatures.drawFeature(testPt2);<br><br>Firebug output:<br><div class="nodeChildBox"><div class="nodeBox emptyNodeBox repIgnore">
<div class="nodeLabel"><span class="nodeLabelBox repTarget"><<span class="nodeTag">circle</span><span class="nodeAttr editGroup"> <span class="nodeName editable">id</span>="<span class="nodeValue editable">OpenLayers.Geometry.Point_145</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">cx</span>="<span class="nodeValue editable">350.12444444444463</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">cy</span>="<span class="nodeValue editable">341.0222222222221</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">r</span>="<span class="nodeValue editable">0</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">fill</span>="<span class="nodeValue editable">red</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">fill-opacity</span>="<span class="nodeValue editable">1</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">stroke</span>="<span class="nodeValue editable">none</span>"</span><span class="nodeBracket editable insertBefore">/></span></span></div>
</div><div class="nodeBox emptyNodeBox repIgnore"><div class="nodeLabel"><span class="nodeLabelBox repTarget"><<span class="nodeTag">circle</span><span class="nodeAttr editGroup"> <span class="nodeName editable">id</span>="<span class="nodeValue editable">OpenLayers.Geometry.Point_143</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">cx</span>="<span class="nodeValue editable">304.6133333333337</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">cy</span>="<span class="nodeValue editable">341.0222222222221</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">r</span>="<span class="nodeValue editable">6</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">fill</span>="<span class="nodeValue editable">#ee9900</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">fill-opacity</span>="<span class="nodeValue editable">0.4</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">stroke</span>="<span class="nodeValue editable">#ee9900</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">stroke-opacity</span>="<span class="nodeValue editable">1</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">stroke-width</span>="<span class="nodeValue editable">1</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">stroke-linecap</span>="<span class="nodeValue editable">round</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">pointer-events</span>="<span class="nodeValue editable">visiblePainted</span>"</span><span class="nodeAttr editGroup"> <span class="nodeName editable">cursor</span>="<span class="nodeValue editable"></span>"</span><span class="nodeBracket editable insertBefore">/><br>
<br>The pointRadius is changed to 0, the fillOpacity is changed to 1, strokeColor is changed to "none", and other default attributes are gone causing the symbol not to display in the map. Trying:<br><br>myFeatures.drawFeature(testPt2, {fillColor: 'red'});<br>
<br>gives two identical points with no attributes changed for the second point. In my actual code I am changing a point'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: 'red'});<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 "none", 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've missed please let me know, otherwise this may be a bug.<br>
<br>Thanks,<br>Ian<br></span></span></div></div></div></div>