I have a map with WMS layer. And want to zoom to selected object. Now i use GetCapabilities from Geoserver and zoom to bbox of whole layer.
So how to do what i want?

Or can u tell me how to get feature bbox from Capabilities? Or how to get FeatureInfo without clicking on map?


                       //myVecLayer is WFS layer

Its do something strange. If feature shows in map window it will be zoomd to it. But if not shows get a error TypeError: info_id[0] is undefined. What is wrong?


Ok now this is Request method

                                    success: function(e){

its ok. But how to get bbox from there?


Now i use a GeoExt.FeatureStore to zoom to feature.
But i have a problem i try zoom_store.layer.getFeaturesByAttribute("id",'5'); and all work. But if i use variable zoom_store.layer.getFeaturesByAttribute("id",some_variable); i get error TypeError: info_id[0] is undefined. Why its heppening?

  • How did you selected the object in the first place? I guess you already did a WMS GetFeatureInfo or a WFS GetFeaure request to do the selection? Or is the selection just done "visually" with a CQL filter? Jul 31, 2012 at 7:07
  • i use CQL filter.
    – Kliver Max
    Jul 31, 2012 at 7:52
  • @Kliver Max, first of all, check out if you have info_id[x] and then run your zooming code...
    – urcm
    Jul 31, 2012 at 9:27
  • I change getFeaturesByAttribute to getFeatureByFidand all works fine. I dont know whats wrong with getFeaturesByAttribute maybe this Returns an array of features that have the given attribute key set to the given value. Comparison of attribute values takes care of datatypes, e.g. the string ‘1234’ is not equal to the number 1234.
    – Kliver Max
    Jul 31, 2012 at 9:43

3 Answers 3


In order to get the bbox you can use the same CQL filter in a WFS GetFeature request, and enable "feature bounding" in the WFS options to make it generate the bbox. This will unfortunately also give you the full feature contents, if you just want the BBOX there is a WPS process that returns just the BBOX instead.

  • im update question. And try do request but how parse it?
    – Kliver Max
    Jul 31, 2012 at 8:18
  • I'm not familiar with OL enough, but surely there are ways to parse GML? Regardless, if you load the response in a DOM you can just go for the element representing the bounding box of the collection Jul 31, 2012 at 10:34

So after all i use this.
1. Create GeoExt.FeatureStore.

                    zoom_store = new GeoExt.data.FeatureStore({
                                layer: myVecLayer,
                                fields: [
                                    {name: 'id', type: 'int'},
                                    {name: 'mydata', type: 'String'}
                                 proxy: new GeoExt.data.ProtocolProxy({
                                    protocol: new OpenLayers.Protocol.WFS({
                                        version: "1.0.0",
                                        url: "http://localhost:8080/geoserver/wfs",
                                        featureType: "filedata_temp",
                                        featureNS: "http://www.opengeospatial.net/cite",
                                autoLoad: true

2 Create atother one layer.

vectorLayer = new OpenLayers.Layer.Vector("Editable features");

3 Add features to this layer.


4 Zoom to this layer.


I will glad if u give me something more usefull.


I don't know if you solve the problem but you can try this:


Works for me

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.