* Hello all this was my q:*
Diego M. wrote > > I'm looking for the best way to apply a search function on my map. > am working on Vector Layer + Geoserver + PostgreSQL. > > I want to implement search functionality so that whenever a user gives a > name or id of the feature in search box, he should be zoomed to that > particular feature on the map. > > * I am thankful to Mr.Phil Scadden. he has helping me with it. he suggest me to do this :* Phil Scadden wrote > > If layer is on the server, then do filter with WFS to fetch features. > Add them to a "selected" vector layer on the map and then zoomtoExtent > for the selected vector layer. This works for WFS spatial searches too - > (search within polygon, DWithin etc). > *here is my previous post:* http://osgeo-org.1560.n6.nabble.com/How-to-apply-a-Search-Function-td4364140.html * So, I was following the steps but since I have no that much experience in this field, I'm stuck :/ would anybody please review my code and let me know what's wrong ? Thank you so much in advance.* *first, I need to know how wfsprotocol.read should be called in response to the input submit. my form in body part is :* <form name="form" id="form"> <input type="submit" value="submet" id="searchText" /> <input type="text" name="Search" id="searchText" value="Enter... " /> </form> * it seems like the code cannot recognize the input text. all the features are displaying again ! it had to be the one which user input* var filter = new OpenLayers.Filter.Logical({ type: OpenLayers.Filter.Logical.AND, filters: [ new OpenLayers.Filter.Comparison({ type: OpenLayers.Filter.Comparison.LIKE, property: "name", value: document.getElementById('searchText').value }), new OpenLayers.Filter.Comparison({ type: OpenLayers.Filter.Comparison.LIKE, property: "id", value: document.getElementById('searchText').value }) ] }); var strategy = new OpenLayers.Strategy.BBOX({ ratio: 1 // makes for easier comparison to map bounds }); var wfsProtocol = new OpenLayers.Protocol.WFS.v1_1_0({ url: "IP/geoserver/wfs", featureType: "Initial_view", featureNS: "http://mapmap.org", srsName: "EPSG:3857", version: "1.1.0", extractAttributes: true, isBaseLayer: false, visibility: true }); var vessels = new OpenLayers.Layer.Vector("The Vessels", { styleMap: styleMap, maxExtent: new OpenLayers.Bounds(-180, -90, 180,90)transform(geographic,mercator), sphericalMercator: true, strategies: [strategy], protocol: wfsProtocol }); map.addLayers([googleMap , vessels]); *wfsProtocol.read ({ filter:filter, callback: processTheQuery, scope: strategy });* function processTheQuery(request) { // the first bit sets the value of sExt to be the a boundingbox on the features returned. // Depending on application logic, this could happen in other places in the code. if (request.data && request.data.bbox) { var b = request.data.bbox; sExt = new OpenLayers.Bounds(b[0],b[1],b[2],b[3]); }else { var fts = request.features; if (fts.length>0) { sExt = fts[0].geometry.getBounds().clone(); for(var i=1;i<fts.length;i++) { sExt.extend(fts[i].geometry.getBounds()); } } } vessels.destroyFeatures(); // get rid of values from previous call // any other process of the returned features goes here eg display attributes in a popup vessels.addFeatures(request.features); map.zoomToExtent(sExt); } -- View this message in context: http://osgeo-org.1560.n6.nabble.com/need-a-little-help-with-this-user-input-wfsprotocol-read-tp4468479p4468479.html Sent from the OpenLayers Users mailing list archive at Nabble.com. _______________________________________________ Users mailing list us...@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/openlayers-users