[OpenLayers-Users] Zoom to a particular feature
Luís de Sousa
luis.a.de.sousa at gmail.com
Thu Jun 2 12:03:19 EDT 2011
Hello everyone, this is really comical.
This code doesn't work:
map.addLayers([selLayer]);
var bds = OpenLayers.Layer.Vector.prototype.getDataExtent.apply(selLayer);
map.zoomToExtent(bds);
But this does:
map.addLayers([selLayer]);
setTimeout("Zoom()", 150);
function Zoom() {
var bds = OpenLayers.Layer.Vector.prototype.getDataExtent.apply(selLayer);
map.zoomToExtent(bds);
}
Funniest thing of all is that for IE, the timeout has be hiked to 300.
So, any elegant way of doing this?
Thank you,
Luís
2011/6/2 Luís de Sousa <luis.a.de.sousa at gmail.com>:
> 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
>
More information about the Users
mailing list