In my prior question, <a href="http://osgeo-org.1803224.n2.nabble.com/Drawing-Colored-Shapes-quot-The-Right-Way-quot-td6360813.html" target="_top" rel="nofollow" link="external"><em>Drawing Colored Shapes "The Right Way"</em></a>, I was curious to know if, as I think they are, StyleMaps are supposed to be read-only mechanisms with no side-effects.<P/>

Seeing some code may help:
<CODE><PRE>
styleMap = new OpenLayers.StyleMap({
  "default": new OpenLayers.Style({
      fillColor: "${getFillColor}", // call the context's method
    }, {
      context: {
        getFillColor: function (feature) {
          if (typeof feature.attributes.fillColor === "undefined" || feature.attributes.fillColor === null) {
            <STRONG><FONT COLOR="red">feature.attributes.fillColor = desiredColorFromScopeClosure;</FONT></STRONG>
            return desiredColorFromScopeClosure;
          } else {
            return feature.attributes.fillColor;
          }
        }
      }
    }
  });
</PRE></CODE>

I'm not happy that the code I inherited changes <EM>feature</EM> in the middle of a getter.  But this seems to be the only way the author knew how to set attributes.fillColor <em>prior</em> to drawing.<P/>

I'd like to not have to use one StyleMap to draw and another to render.<P/>

-Walt Stoneburner, <em>wls@wwco.com</em>

        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://osgeo-org.1803224.n2.nabble.com/Drawing-Colored-Shapes-The-Right-Way-tp6360813p6368817.html">Re: Drawing Colored Shapes &quot;The Right Way&quot; (code sample)</a><br/>
Sent from the <a href="http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Users-f1822463.html">OpenLayers Users mailing list archive</a> at Nabble.com.<br/>