[OpenLayers-Dev] rules and filters. i'm confused

Bart van den Eijnden (OSGIS) bartvde at osgis.nl
Tue May 20 12:17:24 EDT 2008


I think you need to do something like:

var rulePopGreat = new OpenLayers.Rule(
         {
             filter: new OpenLayers.Filter.Comparison({
               type: OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO,
               property: "POP2000",
               value: 500000 }),
             symbolizer: {
                 Polygon: {fillColor: "#FFFF00", strokeColor: "gray"}
             }
         }
 );

Best regards,
Bart

Eric Lemoine wrote:
> Hi. I think you must add your filters to a rule object then add the
> rule to the style object. Can't really check right now, am on a cell
> phone. Cheers
>
> 2008/5/20, Dejung Gewissler <dejung.gewissler at oit.state.nj.us>:
>   
>> Thanks Eric. I've changed my OpenLayers.Rule.Comparison to
>> OpenLayers.Filter.Comparison and the data loads ok. The problem I face
>> now is that all the features are rendered with the else filter and the
>> comparison filters aren't honored.
>>
>> var GeoJSON_style = new OpenLayers.Style();
>> var rulePopGreat = new OpenLayers.Filter.Comparison(
>>         {
>>             type: OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO,
>>             property: "POP2000",
>>             value: 500000,
>>             symbolizer: {
>>                 Polygon: {fillColor: "#FFFF00", strokeColor: "gray"}
>>             }
>>         }
>> );
>> var elseRule = new OpenLayers.Filter(
>>         {elseFilter: true,
>>             symbolizer: {Polygon: {fillColor: "#FFFFFF", strokeColor:
>> "gray"}}
>>         }
>> );
>> GeoJSON_style.addRules([rulePopGreat, elseRule]);
>> var GeoJSON = new OpenLayers.Layer.GML("GeoJSON Vectors",
>> "County_JSON_Simplified.json",
>>         {visibility:false, maxResolution:5000, minResolution:1, format:
>> OpenLayers.Format.GeoJSON,
>>             styleMap: new OpenLayers.StyleMap({
>>                 "default": GeoJSON_style})
>>         }
>> );
>>
>> Thanks,
>> Dejung
>>
>> Eric Lemoine wrote:
>>     
>>> With 2.6 and trunk you should indeed OpenLayers.Filter.Comparison.
>>>
>>> --
>>> Eric
>>>
>>>       
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
>
>
>   


-- 
Bart van den Eijnden
OSGIS, Open Source GIS
bartvde at osgis.nl
http://www.osgis.nl




More information about the Dev mailing list