Thanks Bart and Eric! I got it to work. Here is what worked:

var GeoJSON_style = new OpenLayers.Style();
// create a rule with a filter and symbolizer that will color the feature based on the attribute POP2000
    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: "green"}
        }       
    });

    var rulePopLess = new OpenLayers.Rule({
        filter: new OpenLayers.Filter.Comparison({
            type: OpenLayers.Filter.Comparison.LESS_THAN,
            property: "POP2000",
            value: "200000"
        }),
        symbolizer: {
            Polygon: {fillColor: "#00FFFF", strokeColor: "blue"}
        }
    });

    var elseRule = new OpenLayers.Rule(
        {elseFilter: true,
            symbolizer: {Polygon: {fillColor: "#FFFFFF", strokeColor: "red"}}
        }
    );

    GeoJSON_style.addRules([rulePopGreat, rulePopLess, 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 again everyone!
-Dejung



Bart van den Eijnden (OSGIS) wrote:
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 <[EMAIL PROTECTED]>:
 
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
[email protected]
http://openlayers.org/mailman/listinfo/dev


 



--
Dejung Gewissler
New Jersey Office of Information Technology
Office of Geographic Information Systems
200 Riverview Plaza
PO Box 212, Trenton, NJ 08625-0212

609.777.3754
_______________________________________________
Dev mailing list
[email protected]
http://openlayers.org/mailman/listinfo/dev

Reply via email to