[OpenLayers-Users] Zoom to a particular feature

Luís de Sousa luis.a.de.sousa at gmail.com
Thu Jun 2 10:59:11 EDT 2011


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 <RDell at catawbacountync.gov>:
> 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: openlayers-users-bounces at lists.osgeo.org [mailto:openlayers-users-bounces at lists.osgeo.org] On Behalf Of Luís de Sousa
> Sent: Wednesday, June 01, 2011 10:45 AM
> To: users at openlayers.org
> 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
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>


More information about the Users mailing list