0

I am displaying the attribute data in the popup on clicking on the map using openlayers,geoext. But i want to hide some fields(fid,.....) from the table in the popup. How to do this. Below is my code

var control = new OpenLayers.Control.WMSGetFeatureInfo({ url: "http://localhost:8080/geoserver/cite/wms", "LAYERS": 'xxxxxx', srs:'EPSG:3857' });

        control.events.on({
            getfeatureinfo: function(event) {
                //close existing popup
                if (popup) {
                    popup.destroy();
                }
                popup = new GeoExt.Popup({
                    title: "Feature Info",
                    map: mapPanel.map,
                    lonlat: mapPanel.map.getLonLatFromViewPortPx(event.xy),
                    width: 250,
                    autoScroll: true,
                    collapsible: true,
                    bodyStyle: {padding: 5},
                    location:event.xy,
                    html: event.text
                    });

                popup.show();
                }
        });

 mapPanel.map.addControl(control);
    control.activate();
3

If you have control over the geoserver and you use the html format, you could modify the template server side. Otherwise I can think of retrieving the FeatureInfo as GML2 or text and modify if client-side. But I don't know how this might be implemented in openlayers.

  • please tell me how to modify the template server side. – user46218 Jul 4 '16 at 6:40
  • Have you read the link in my answer? Have a look at custom templates. – ulrich Jul 4 '16 at 6:51
2

For the specific case of GeoServer you can also add the propertyName vendor option to the request and enumerate the attributes you want to include in the response:

http://docs.geoserver.org/latest/en/user/services/wms/vendor.html#propertyname

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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