Thank you Ralph that was very close. I can indeed filter a WFS layer that way, e.g. request Texas from the topp:states layer in Geoserver.
Problem is: zoomToExtent returns null. I browsed the list and found this old thread: http://lists.osgeo.org/pipermail/openlayers-users/2008-September/007531.html But the solution given there, using OpenLayers.Layer.Vector.prototype.getDataExtent.apply, isn't working either. So the issue is now resumed to zooming to a WFS layer. Anyone knows how? Thank you, Luís 2011/6/1 Ralph Dell <[email protected]>: > Hopefully I am not misunderstanding your question. > > Set up a filter, add it to your vector layer, and then zoom to the feature if > that is your objective > > filter = new OpenLayers.Filter.Comparison({ > type: OpenLayers.Filter.Comparison.EQUAL_TO, > property: "foo", > value: '123' > }); > > selLayer = new OpenLayers.Layer.Vector("Selected", { > strategies: [new OpenLayers.Strategy.Fixed()], > styleMap: styleMap, > filter: filter, > protocol: protocol > }); > > map.zoomToExtent(selLayer.getDataExtent()); > > > Ralph Dell > > -----Original Message----- > From: [email protected] > [mailto:[email protected]] On Behalf Of Luís de Sousa > Sent: Wednesday, June 01, 2011 10:45 AM > To: [email protected] > Subject: [OpenLayers-Users] Zoom to a particular feature > > Hello everyone, > > I have this webpage where I must zoom to a particular feature that > matches a string given by the user. A similar issue has been > previously raised in this thread: > > http://lists.osgeo.org/pipermail/openlayers-users/2011-March/019820.html > > Where a GetFeature request is suggested to obtain the bounding boxes > of the layer's features. The problem is that I have layers with about > a thousand features, which quickly clog the webpage with a slow > connection. > > My question is: can I obtain the bounding box for a particular feature > that matches a particular condition such as ATTRIBUTE=KEY with a > GetFeature request? Or using a different method? > > Thank you, > > Luís > _______________________________________________ > Users mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/openlayers-users > _______________________________________________ Users mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/openlayers-users
