<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Thanks Bart and Eric! I got it to work. Here is what worked:<br>
<br>
var GeoJSON_style = new OpenLayers.Style();<br>
// create a rule with a filter and symbolizer that will color the
feature based on the attribute POP2000<br>
var rulePopGreat = new OpenLayers.Rule({<br>
filter: new OpenLayers.Filter.Comparison({<br>
type: OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO,<br>
property: "POP2000",<br>
value: "500000"<br>
}),<br>
symbolizer: {<br>
Polygon: {fillColor: "#FFFF00", strokeColor: "green"}<br>
} <br>
});<br>
<br>
var rulePopLess = new OpenLayers.Rule({<br>
filter: new OpenLayers.Filter.Comparison({<br>
type: OpenLayers.Filter.Comparison.LESS_THAN,<br>
property: "POP2000",<br>
value: "200000"<br>
}),<br>
symbolizer: {<br>
Polygon: {fillColor: "#00FFFF", strokeColor: "blue"}<br>
}<br>
});<br>
<br>
var elseRule = new OpenLayers.Rule(<br>
{elseFilter: true,<br>
symbolizer: {Polygon: {fillColor: "#FFFFFF", strokeColor:
"red"}}<br>
}<br>
);<br>
<br>
GeoJSON_style.addRules([rulePopGreat, rulePopLess, elseRule]);<br>
<br>
var GeoJSON = new OpenLayers.Layer.GML("GeoJSON Vectors",
"County_JSON_Simplified.json", <br>
{visibility:false, maxResolution:5000, minResolution:1, format:
OpenLayers.Format.GeoJSON,<br>
styleMap: new OpenLayers.StyleMap({<br>
"default": GeoJSON_style}) <br>
}<br>
);<br>
<br>
Thanks again everyone!<br>
-Dejung<br>
<br>
<br>
<br>
Bart van den Eijnden (OSGIS) wrote:
<blockquote cite="mid:4832F994.7030005@osgis.nl" type="cite">I think
you need to do something like:
<br>
<br>
var rulePopGreat = new OpenLayers.Rule(
<br>
{
<br>
filter: new OpenLayers.Filter.Comparison({
<br>
type:
OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO,
<br>
property: "POP2000",
<br>
value: 500000 }),
<br>
symbolizer: {
<br>
Polygon: {fillColor: "#FFFF00", strokeColor: "gray"}
<br>
}
<br>
}
<br>
);
<br>
<br>
Best regards,
<br>
Bart
<br>
<br>
Eric Lemoine wrote:
<br>
<blockquote type="cite">Hi. I think you must add your filters to a
rule object then add the
<br>
rule to the style object. Can't really check right now, am on a cell
<br>
phone. Cheers
<br>
<br>
2008/5/20, Dejung Gewissler <a class="moz-txt-link-rfc2396E" href="mailto:dejung.gewissler@oit.state.nj.us"><dejung.gewissler@oit.state.nj.us></a>:
<br>
<blockquote type="cite">Thanks Eric. I've changed my
OpenLayers.Rule.Comparison to
<br>
OpenLayers.Filter.Comparison and the data loads ok. The problem I face
<br>
now is that all the features are rendered with the else filter and the
<br>
comparison filters aren't honored.
<br>
<br>
var GeoJSON_style = new OpenLayers.Style();
<br>
var rulePopGreat = new OpenLayers.Filter.Comparison(
<br>
{
<br>
type:
OpenLayers.Filter.Comparison.GREATER_THAN_OR_EQUAL_TO,
<br>
property: "POP2000",
<br>
value: 500000,
<br>
symbolizer: {
<br>
Polygon: {fillColor: "#FFFF00", strokeColor: "gray"}
<br>
}
<br>
}
<br>
);
<br>
var elseRule = new OpenLayers.Filter(
<br>
{elseFilter: true,
<br>
symbolizer: {Polygon: {fillColor: "#FFFFFF", strokeColor:
<br>
"gray"}}
<br>
}
<br>
);
<br>
GeoJSON_style.addRules([rulePopGreat, elseRule]);
<br>
var GeoJSON = new OpenLayers.Layer.GML("GeoJSON Vectors",
<br>
"County_JSON_Simplified.json",
<br>
{visibility:false, maxResolution:5000, minResolution:1, format:
<br>
OpenLayers.Format.GeoJSON,
<br>
styleMap: new OpenLayers.StyleMap({
<br>
"default": GeoJSON_style})
<br>
}
<br>
);
<br>
<br>
Thanks,
<br>
Dejung
<br>
<br>
Eric Lemoine wrote:
<br>
<blockquote type="cite">With 2.6 and trunk you should indeed
OpenLayers.Filter.Comparison.
<br>
<br>
--
<br>
Eric
<br>
<br>
</blockquote>
</blockquote>
_______________________________________________
<br>
Dev mailing list
<br>
<a class="moz-txt-link-abbreviated" href="mailto:Dev@openlayers.org">Dev@openlayers.org</a>
<br>
<a class="moz-txt-link-freetext" href="http://openlayers.org/mailman/listinfo/dev">http://openlayers.org/mailman/listinfo/dev</a>
<br>
<br>
<br>
</blockquote>
<br>
<br>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<font color="#000000"><b>Dejung Gewissler</b></font><br>
New Jersey Office of Information Technology<br>
<font color="#006600">Office of Geographic Information Systems</font><br>
200 Riverview Plaza<br>
PO Box 212, Trenton, NJ 08625-0212<br>
<br>
609.777.3754
</div>
</body>
</html>