[Geoserver-users] GML via GetFeatureInfo -- what newbie thing am I missing?

Hullo all,

I’m using GeoServer with an OpenLayers client, and I want to implement a “zoom-to-clicked-polygon” feature. I just need the bounding box for the clicked feature, which I know I can obtain with a GetFeatureInfo call. The following is pretty straight from the click handler example on openlayers.org:

OpenLayers.Util.getElement(‘nodelist’).innerHTML = “Loading… please wait…”;
var url = map.layers[0].getFullRequestString({
REQUEST: “GetFeatureInfo”,
EXCEPTIONS: “application/vnd.ogc.se_xml”,
BBOX: map.getExtent().toBBOX(),
X: e.xy.x,
Y: e.xy.y,
INFO_FORMAT: ‘text/plain’,
QUERY_LAYERS: map.layers[0].params.LAYERS,
FEATURE_COUNT: 1,
srs: ‘EPSG:26916’,
styles: ‘’,
layers: ‘mmas:cities’,
WIDTH: map.size.w,
HEIGHT: map.size.h},
http://my.server/geoserver/wms
);
OpenLayers.loadURL(url, ‘’, this, setHTML, setHTML);
Event.stop(e);
});
}

Then the setHTML function does nifty things with the response parameter.

Now, if I change the INFO_FORMAT to ‘application/vnd.ogc.gml’, I can obtain GML from the server which contains the bounding box I want. I’ve tested this by obtaining the URL constructed by the call above (after the INFO_FORMAT swap), and poking it into a browser. Boom, back comes nice XML. In my JavaScript…not so much, null response.responseXML.

I have seen references in my searching to setting DUMP to true on layers and the template to ‘foo’ or ‘dummy’, but all that discussion referred to that as if it were a WKT (Well-Known Technique) and so didn’t specify where one goes about setting these nice things.

Alms to the poor?

It might be a more OpenLayers-specific sort of thing, I’ll cross-post there.

TIA,

Rick Wayne
UW Soil Science

Rick Wayne ha scritto:

Hullo all,

I'm using GeoServer with an OpenLayers client, and I want to implement a "zoom-to-clicked-polygon" feature. I just need the bounding box for the clicked feature, which I know I can obtain with a GetFeatureInfo call. The following is pretty straight from the click handler example on openlayers.org:

           OpenLayers.Util.getElement('nodelist').innerHTML = "Loading... please wait...";
            var url = map.layers[0].getFullRequestString({
                            REQUEST: "GetFeatureInfo",
                            EXCEPTIONS: "application/vnd.ogc.se_xml",
                            BBOX: map.getExtent().toBBOX(),
                            X: e.xy.x,
                            Y: e.xy.y,
                            INFO_FORMAT: 'text/plain',
                            QUERY_LAYERS: map.layers[0].params.LAYERS,
                            FEATURE_COUNT: 1,
                            srs: 'EPSG:26916',
                            styles: '',
                            layers: 'mmas:cities',
                            WIDTH: map.size.w,
                            HEIGHT: map.size.h},
                            "http://my.server/geoserver/wms"
                            );
            OpenLayers.loadURL(url, '', this, setHTML, setHTML);
            Event.stop(e);
      });
      }

Then the setHTML function does nifty things with the response parameter.

Now, if I change the INFO_FORMAT to 'application/vnd.ogc.gml', I can obtain GML from the server which contains the bounding box I want. I've tested this by obtaining the URL constructed by the call above (after the INFO_FORMAT swap), and poking it into a browser. Boom, back comes nice XML. In my JavaScript...not so much, null response.responseXML.

I have seen references in my searching to setting DUMP to true on layers and the template to 'foo' or 'dummy', but all that discussion referred to that as if it were a WKT (Well-Known Technique) and so didn't specify /where/ one goes about setting these nice things.

Dump=true is a setting that's required for MapServer to properly
honor GetFeatureInfo, in GeoServer there is no equivalent.
However, if the request works by itself and does not when run from
OL, I believe you'll have to ask on the OL-users ml.

Cheers
Andrea