[OpenLayers-Users] using openlayers.rule with existing style

Brenningmeyer, Todd tbrenningmeyer at maryville.edu
Wed Aug 20 11:50:32 EDT 2008


Hello,
I have a series of points that are symbolized with an sld.  Each point represents a site of a particular period (classical, byzantine, etc.).  What I want to do is allow the user to turn points on and off by clicking a checkbox on the side (all points are in a "sites" table in postgresql).  I'm currently using a filter in the sld to symbolize sites of each period differently.  Can I apply a new filter using openlayers.rule with a new openlayers.filter to turn layers on and off?  The function below is called when someone clicks on the checkbox.  The code below comes up with an "OpenLayers.rule is not a constructor" error when it is executed.  I suppose my question is whether or not the features can be filtered to display or not display using this method and if so how would I do this?  If it's not a reasonable approach does anyone have ideas about how something like this could be done?  I would rather not separate all of the features into different files and an sld with individual styles for each possible combination of clicks could get very long.
Thanks,
Todd
 
        function setStyle(index) {
          var rule = new OpenLayers.rule({
          filter: new OpenLayers.Filter.Comparison({
           type: OpenLayers.Filter.Comparison.EQUAL_TO,
           property: "plan_inkd",
           value: "1"
          }),
          symbolizer: {
           Point: { fillColor:"FFFF00", strokeColor: "blue"}
           }
          });
            gmlLayer.styleMap.styles["default"] = sld.namedLayers["Villages"].userStyles[0].addRule(rule);   
            gmlLayer.redraw();
        }



More information about the Users mailing list