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

Garthanos lancelot at inetnebr.com
Fri May 23 13:47:45 EDT 2008



So basically you solved this issue by switching to GeoJSON Layer Type.. I
need the GML layer to work or the WFS layer to integrate filters (as well as
bbox)

Basically seems like the GML Layer type in 2.6 has no styling capability is
that correct?



Dejung Gewissler-2 wrote:
> 
> 
> 
> 
>   
> 
> 
> 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 <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 
>     
>     
>     
>   
>   
>   
> 
> 
> -- 
> 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
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev
> 
> 

-- 
View this message in context: http://www.nabble.com/rules-and-filters.-i%27m-confused-tp17329314p17430139.html
Sent from the OpenLayers Dev mailing list archive at Nabble.com.




More information about the Dev mailing list