<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<title></title>
</head>
<body text="#000000" bgcolor="#ffffff">
Hi Aparna,<br>
what Arnd wrote is that you can create an OGC filter for your WFS as
in<br>
<br>
var ogcFilter = new OpenLayers.Filter.Comparison({<br>
type: OpenLayers.Filter.Comparison.EQUAL_TO,<br>
property: "id",<br>
value: someId<br>
});<br>
<br>
and then use it in your protocol:<br>
<br>
var state = new OpenLayers.Layer.Vector("K", {<br>
strategies: [new OpenLayers.Strategy.Fixed()],<br>
protocol: new OpenLayers.Protocol.WFS({<br>
version: "1.1.0",<br>
url: "<a moz-do-not-send="true"
href="http://localhost:8085/geoserver/wfs">http://localhost:8085/geoserver/wfs</a>",<br>
params: {CQL_FILTER: 'SCHCAT = 3'}, <br>
featureType: "karf",<br>
featureNS: "<a moz-do-not-send="true"
href="http://opengeo.org/India">http://opengeo.org/India</a>",<br>
defaultFilter: ogcFilter<br>
})<br>
});<br>
<br>
Or have a look here:
<a class="moz-txt-link-freetext" href="http://openlayers.org/dev/examples/wfs-filter.js">http://openlayers.org/dev/examples/wfs-filter.js</a><br>
<br>
Christoph<br>
<br>
<br>
On 03.01.2012 11:51, Aparna wrote:
<blockquote
cite="mid:CAJSds0OWb2YcSGNWmVBzi_RO8UuKd+eNXQUxNUs6oq-feo7fcg@mail.gmail.com"
type="cite">This does not seem to be working either. <br>
<br>
var state = new OpenLayers.Layer.Vector("K", {<br>
strategies: [new OpenLayers.Strategy.Fixed()],<br>
protocol: new OpenLayers.Protocol.WFS({<br>
version: "1.1.0",<br>
url: "<a moz-do-not-send="true"
href="http://localhost:8085/geoserver/wfs">http://localhost:8085/geoserver/wfs</a>",<br>
params: {CQL_FILTER: 'SCHCAT = 3'}, <br>
featureType: "karf",<br>
featureNS: "<a moz-do-not-send="true"
href="http://opengeo.org/India">http://opengeo.org/India</a>"<br>
<br>
})<br>
});<br>
map.addLayer(state);<br>
<br>
<br>
<br>
<div class="gmail_quote">On Wed, Dec 28, 2011 at 12:07 AM, Arnd
Wippermann <span dir="ltr"><<a moz-do-not-send="true"
href="mailto:arnd.wippermann@web.de">arnd.wippermann@web.de</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
0.8ex; border-left: 1px solid rgb(204, 204, 204);
padding-left: 1ex;">
<div>
<div dir="ltr" align="left"><span><font color="#0000ff"
face="Arial">Hi,</font></span></div>
<div dir="ltr" align="left"><span></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff"
face="Arial">i think, you cannot use filter to load
static data. OpenLayers have to load the whole file
and doesnot use the filter to serialize only parts of
the file and add them as features.</font></span></div>
<div dir="ltr" align="left"><span></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff"
face="Arial">If you request the data from a provider,
which evaluates the filter like WFS, filter does work.</font></span></div>
<div dir="ltr" align="left"><span></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff"
face="Arial">Instead you can use a styleMap to display
only a set of features.</font></span></div>
<div dir="ltr" align="left"><span></span> </div>
<div dir="ltr" align="left"><span><font color="#0000ff"
face="Arial">Arnd</font></span></div>
<div dir="ltr" align="left"><span></span> </div>
<div dir="ltr" align="left">
<hr>
</div>
<div dir="ltr" align="left"><font face="Tahoma"><b>Von:</b>
<a moz-do-not-send="true"
href="mailto:openlayers-users-bounces@lists.osgeo.org"
target="_blank">openlayers-users-bounces@lists.osgeo.org</a>
[mailto:<a moz-do-not-send="true"
href="mailto:openlayers-users-bounces@lists.osgeo.org"
target="_blank">openlayers-users-bounces@lists.osgeo.org</a>]
<b>Im Auftrag von </b>Aparna<br>
<b>Gesendet:</b> Montag, 26. Dezember 2011 12:15<br>
<b>An:</b> <a moz-do-not-send="true"
href="mailto:users@openlayers.org" target="_blank">users@openlayers.org</a><br>
<b>Betreff:</b> [OpenLayers-Users] Filtering a GeoJSON
layer<br>
</font><br>
</div>
<div>
<div class="h5">
filtering either after projection or in the
protocol->format->filter does not seem to be
working at all. <br>
<br>
var state = new OpenLayers.Layer.Vector("State", {<br>
projection: map.displayProjection, <br>
filter: new
OpenLayers.Filter.Comparison({<br>
type:
OpenLayers.Filter.Comparison.EQUAL_TO,<br>
property: 'SCHMGT',<br>
value: 2<br>
}), <br>
strategies: [new OpenLayers.Strategy.Fixed()],<br>
protocol: new OpenLayers.Protocol.HTTP({<br>
url:
"klm/GIS.json", <br>
format: new
OpenLayers.Format.GeoJSON({
<br>
extractAttributes:
true <br>
<br>
})<br>
})<br>
});<br>
<br>
How does one implement a filter?? </div>
</div>
</div>
</blockquote>
</div>
<br>
<pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a>
<a class="moz-txt-link-freetext" href="http://lists.osgeo.org/mailman/listinfo/openlayers-users">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a>
</pre>
</blockquote>
<br>
</body>
</html>