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

Brenningmeyer, Todd tbrenningmeyer at maryville.edu
Fri Aug 22 07:51:46 EDT 2008


Eric,
Thanks.  That helped and I now see that I may be able to do this with the addUniqueValueRules?  At least it seems that this is the case.  I was unable to get the symbolizer with {display: "none"} to hide the selected features.  When I change the fillcolor the color changes on redraw but when display: "none" is used nothing seems to change.  Is there another way to set this?
Thanks again,
Todd 

________________________________

From: Eric Lemoine [mailto:eric.c2c at gmail.com]
Sent: Thu 8/21/2008 1:15 AM
To: Brenningmeyer, Todd; users at openlayers.org
Subject: Re: [OpenLayers-Users] using openlayers.rule with existing style



Hi. A Rule object as opposed to a Filter object must be passed to
addRules, the code snippet you first posted had this right. If your
goal is to not display points matching some criteria, your rule's
symbolizer will be {display: "none"}. Also, one thing to pay attention
to: if the feature property is an integer your must have an integer as
your filter's value (value: "1" looks suspicious to me, but i dont
know what your data is). Hope this helps. Eric

2008/8/20, Brenningmeyer, Todd <tbrenningmeyer at maryville.edu>:
> 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();
>         }
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>





More information about the Users mailing list