In my prior question, 
http://osgeo-org.1803224.n2.nabble.com/Drawing-Colored-Shapes-quot-The-Right-Way-quot-td6360813.html
Drawing Colored Shapes "The Right Way" , I was curious to know if, as I
think they are, StyleMaps are supposed to be read-only mechanisms with no
side-effects.


Seeing some code may help:

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) {
            feature.attributes.fillColor = desiredColorFromScopeClosure;
            return desiredColorFromScopeClosure;
          } else {
            return feature.attributes.fillColor;
          }
        }
      }
    }
  });


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


I'd like to not have to use one StyleMap to draw and another to render.


-Walt Stoneburner, [email protected]


--
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Drawing-Colored-Shapes-The-Right-Way-tp6360813p6368817.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to