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

Brenningmeyer, Todd tbrenningmeyer at maryville.edu
Wed Aug 20 17:36:59 EDT 2008


I was able to get the function to run without crashing but the rules I apply do not seem to change the characteristics of the features.  None of the features are filtered when I apply the "filter.comparison.EQUAL_TO".  Am I applying this correctly or does it not work the way I thought?  Any help is appreciated.
Todd
 
        function setStyle(index) { 
         if(index == 'all'){       
            gmlLayer.styleMap.styles["default"] = sld.namedLayers["Inked"].userStyles[0];            
            gmlLayer.redraw();
            } else {
            var rule = new OpenLayers.Filter.Comparison({
           type: OpenLayers.Filter.Comparison.EQUAL_TO,
           property: "plan_inkd",
           value: "0",
           symbolizer: {fillColor:"FFFF00"}
          })
          sld.namedLayers["NotInked"].userStyles[0].addRules([rule]);
            gmlLayer.styleMap.styles["default"] = sld.namedLayers["NotInked"].userStyles[0];            
            gmlLayer.redraw();
        }            
      }

________________________________

From: Brenningmeyer, Todd
Sent: Wed 8/20/2008 10:50 AM
To: users at openlayers.org
Subject: using openlayers.rule with existing style


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