Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I'm trying to set up a Rule using the Function Filter. But it does not work: the lines on that layer are just black. And more importantly, the filtering function is never executed.

Can someone please point out what is the mistake that i'm making?

Here is the code.

Thank you for your time and kind concern.

var my_filter = new OpenLayers.Filter.Function(
    function(attributes) {
       console.log(attributes);
       var x=0; 
       return true;

    });
var ruleLow = new OpenLayers.Rule({
    filter:my_filter ,
  symbolizer: {pointRadius: 10, fillColor: "green",
               fillOpacity: 0.5, strokeColor: "green"}
  });


var my_style=new OpenLayers.Style( null,ruleLow);

var my_style_map=new OpenLayers.StyleMap({
    "temporary":my_style,
    "default":my_style,
    "select":my_style

});
this.vectors= new OpenLayers.Layer.Vector(
    "Vector Layer",
    {
        styleMap:my_style_map,
        renderers:this.renderer,
    }
);
share|improve this question

1 Answer 1

up vote 0 down vote accepted

I'm glad to share with you how to use the OpenLayers.Filter.Function!! (so I solved the problem that I had): that what I had to change basically.

Thanks anyways.

var my_filter = new OpenLayers.Filter.FeatureId({
    **type: OpenLayers.Filter.Function,**
    evaluate:function(attributes) {
       console.log(attributes);
       var x=0; 
       return true;

    }
});
var ruleLow = new OpenLayers.Rule({
    filter:my_filter,
  });


var my_style=new OpenLayers.Style( {pointRadius: 7, fillColor: "#FF3300",
               fillOpacity: 0.5, strokeColor: "#FF3300"},**{rules:[ruleLow]}**);

var my_style_map=new OpenLayers.StyleMap({
    "temporary":my_style,
    "default":my_style,
    "select":my_style

});
this.vectors= new OpenLayers.Layer.Vector(
    "Vector Layer",
    {
        styleMap: my_style_map, 
        renderers:this.renderer,
    }
);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.