Skip to main content
Changed JSFiddle URL per abettermaps
Source Link

When using vector layers in OpenLayers, it is always best to use the filter startegy instead of the filter parameter in the layer:

var filterStrategy = new OpenLayers.Strategy.Filter({filter: your_filter_here});

var station = new OpenLayers.Layer.Vector("station", {
    strategies: [ filterStrategy ]
});

and:

$("#button1").click(function () {
    var filter = new OpenLayers.Filter.Logical({
        type: OpenLayers.Filter.Logical.OR,
        filters: [
        new OpenLayers.Filter.Comparison({
            type: OpenLayers.Filter.Comparison.EQUAL_TO,
            property: "id_station",
            value: 2
        })]
    });
    filterStrategy.setFilter(filter);
});

I've built a working example available here:

http://jsfiddle.net/47kyN/https://jsfiddle.net/d8f7120x/2/

When using vector layers in OpenLayers, it is always best to use the filter startegy instead of the filter parameter in the layer:

var filterStrategy = new OpenLayers.Strategy.Filter({filter: your_filter_here});

var station = new OpenLayers.Layer.Vector("station", {
    strategies: [ filterStrategy ]
});

and:

$("#button1").click(function () {
    var filter = new OpenLayers.Filter.Logical({
        type: OpenLayers.Filter.Logical.OR,
        filters: [
        new OpenLayers.Filter.Comparison({
            type: OpenLayers.Filter.Comparison.EQUAL_TO,
            property: "id_station",
            value: 2
        })]
    });
    filterStrategy.setFilter(filter);
});

I've built a working example available here:

http://jsfiddle.net/47kyN/

When using vector layers in OpenLayers, it is always best to use the filter startegy instead of the filter parameter in the layer:

var filterStrategy = new OpenLayers.Strategy.Filter({filter: your_filter_here});

var station = new OpenLayers.Layer.Vector("station", {
    strategies: [ filterStrategy ]
});

and:

$("#button1").click(function () {
    var filter = new OpenLayers.Filter.Logical({
        type: OpenLayers.Filter.Logical.OR,
        filters: [
        new OpenLayers.Filter.Comparison({
            type: OpenLayers.Filter.Comparison.EQUAL_TO,
            property: "id_station",
            value: 2
        })]
    });
    filterStrategy.setFilter(filter);
});

I've built a working example available here:

https://jsfiddle.net/d8f7120x/2/

Source Link

When using vector layers in OpenLayers, it is always best to use the filter startegy instead of the filter parameter in the layer:

var filterStrategy = new OpenLayers.Strategy.Filter({filter: your_filter_here});

var station = new OpenLayers.Layer.Vector("station", {
    strategies: [ filterStrategy ]
});

and:

$("#button1").click(function () {
    var filter = new OpenLayers.Filter.Logical({
        type: OpenLayers.Filter.Logical.OR,
        filters: [
        new OpenLayers.Filter.Comparison({
            type: OpenLayers.Filter.Comparison.EQUAL_TO,
            property: "id_station",
            value: 2
        })]
    });
    filterStrategy.setFilter(filter);
});

I've built a working example available here:

http://jsfiddle.net/47kyN/