[OpenLayers-Users] Re: need a little help with this ( user input & wfsprotocol.read )

Phil Scadden p.scadden at gns.cri.nz
Sun Feb 19 15:40:24 EST 2012


> wfsProtocol.read ({
>               filter:filter,
>         	 callback: processTheQuery,
>               scope: strategy
>           });
> the (user input text) will be sent to the filter,
To be pedantic, the filter is constructed from user input before the read.
>   and if it match any value
> in the DB, that feature will be sent to the processTheQuery func to set the
> new bounds and draw the new selectedLayer with that feature only.
> Do i get it right ?
The "read" will generate a wfs query post to the server. processTheQuery 
has to be able to deal with whatever the server will send back. It has 
to determined from the response whether there are matching features 
returned.
> and if the user insert a wrong value in a search text (which it is not match
> any value in the DB ) , what will happen then ?
You will have features.length of zero in the returned response. I would 
strongly recommend you use firebug to examine both what the read 
generates and what it returns. You can use tools to manually fiddle with 
the POST and see the effect.
> also, selectedLayer has to be a new layer to display the search results
> only. right ?
See earlier posts with the example code, but yes, I create an empty 
vector layer where I display results from searching or filtering. This 
isnt the only way (eg see 
http://openlayers.org/dev/examples/cql-format.js) but it is what works 
for me - I am using WMS for display and WFS for query. This structure 
lets me use a single procedure (processTheQuery) for both spatial 
search, (including a DWITHIN which I use instead of WMSGetFeatureInfo) 
and searching by attributes. You needs may be different so study the 
filtering examples as well. Also look at the SLDSelect example - if this 
works for you, it is fast when have a large number of geometries.

Notice: This email and any attachments are confidential. If received in error please destroy and immediately notify us. Do not copy or disclose the contents.



More information about the Users mailing list