Monday, 13 November 2017

openlayers 2 - How to define filter in WFS layer in order I can show new filter result layer for new filter condition (i.e.redraw the layer according to filter)


I am using OpenLayers 2.12 for this WFS filter purpose. I wanted to redraw filter layer as conditions in filter changes dynamic.


Following is my code in for WFS:


 var ty=OpenLayers.Filter.Comparison.EQUAL_TO;

var propertyOP="name";
var valOP="buil2";
build1 = new OpenLayers.Layer.Vector("WFS", {
strategies: [new OpenLayers.Strategy.BBOX()],
filter: new OpenLayers.Filter.Comparison({
type: ty,
property: propertyOP,
value: ValOP
}),
protocol: new OpenLayers.Protocol.WFS({

srsName:"EPSG:4326",
version: "1.1.0",
url: "http://localhost:8080/geoserver/sol/wfs",
featureType: "ch",
featurePrefix:"sol",
featureNS: "http://localhost:81/sol"/*,
geometryName:"geom"*/
}),
projection: geographic,
styleMap: styleMap

});
map.addLayer(build1);

Now I wanted to make this filter to update and show new filter layer result. In my current code previous filter result remain but show result on previous result. My Filter type,property and value get changed.



Answer



I have solved this question and worked in my case:


build1.filter = new OpenLayers.Filter.Comparison({ 
type: ty,
property: propertyOP,
value: ValOP

});

build1.refresh({force:true});

No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...