4

I'm using the WMSGetFeatureInfo control of Openlayers in order to have a pupop in the map with the WMS layer info. Automatically Openlayers inserts a FID field at the beginning of the popup. Is there a way to hide that field?

more precisely, i'm using this function in my js map file:

   info = new OpenLayers.Control.WMSGetFeatureInfo({
        url: 'http://localhost:8080/geoserver/wms',
        title: 'Identify features by clicking',
        queryVisible: true,
        eventListeners: {
            getfeatureinfo: function(event) {
                map.addPopup(new OpenLayers.Popup.FramedCloud(
                    "chicken",
                    map.getLonLatFromPixel(event.xy),
                    null,
                    event.text,
                    null,
                    true
                ));
            }
        }
    });
    map.addControl(info);

Do you have any suggestion to remove the fid field?

1 Answer 1

1

Accordind to the doc you need to parse the event.features and build your text for the popup:

info = new OpenLayers.Control.WMSGetFeatureInfo({
    url: 'http://localhost:8080/geoserver/wms',
    title: 'Identify features by clicking',
    queryVisible: true,
    eventListeners: {
        getfeatureinfo: function(event) {
            var txt = "";
            for (var i=0, len = event.features.length; i++){
              txt += event.features[i].attributes.YOURATTRIBUTE;
            }

            map.addPopup(new OpenLayers.Popup.FramedCloud(
                "chicken",
                map.getLonLatFromPixel(event.xy),
                null,
                event.text,
                null,
                true
            ));
        }
    }
});
map.addControl(info);

getfeatureinfo : Triggered when a GetFeatureInfo response is received. The event object has a text property with the body of the response (String), a features property with an array of the parsed features, an xy property with the position of the mouse click or hover event that triggered the request, and a request property with the request itself. If drillDown is set to true and multiple requests were issued to collect feature info from all layers, text and request will only contain the response body and request object of the last request.

Your Answer

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

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