[OpenLayers-Users] Zoom to a WFS filter feature
Eric Lemoine
eric.c2c at gmail.com
Tue Nov 27 00:29:33 EST 2007
Hi
getBounds()
On Nov 26, 2007 12:47 PM, goeserver developer <bjoice at firstam.com> wrote:
>
> Hi
>
> I have added a wfs layer with the filter option . Now I want to zoom to it
> .I am be able to do it with :
>
> bounds = new
> OpenLayers.Bounds(-9441241.90017852,4636148.46449042,-8963467.99653102,5159004.74932964);//
> state :ohio
> map.zoomToExtent(bounds);
> but I have to do it Dynamically .How can I get the bounds ? Below is the
> output of that same filter.how can I extract the gml:coordinates .
You can loop over your features' geometries and calculate the bounding
box. Code would loolk like this:
bbox = null;
for (var i = 0; i < wfsLayer.features.length; i++) {
var geometry = wfsLayer.features[i].geometry;
if (bbox == null) {
bbox = geometry.getBounds().clone();
} else {
bbox.extend(geometry.getBounds());
}
}
Warning: absolutely untested!
--
Eric
More information about the Users
mailing list