Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running simple local mapping service based on PostGIS/GeoServer/OpenLayers stack.

Following opengeo tutorial I've tied click events in OpenLayers to WMS GetFeatureInfo call using:'click', map, function (e) {
        var url = "http://localhost:1979/geoserver/wms" 
          + "?REQUEST=GetFeatureInfo"
          + "&EXCEPTIONS=application/vnd.ogc.se_xml"
          + "&BBOX=" + map.getExtent().toBBOX()
          + "&X=" + e.xy.x
          + "&Y=" + e.xy.y
          + "&INFO_FORMAT=text/html"
          + "&FEATURE_COUNT=5"
          + "&SRS=EPSG:3857"
          + "&STYLES="
          + "&WIDTH=" + map.size.w
          + "&HEIGHT=" + map.size.h;,

I've used GeoServer's FreeMarker templates to format the response correctly. The problem I have is that the response I get returns all of the fields from the layer.

Is there a way to select the ones that are relevant to the user?

share|improve this question
up vote 5 down vote accepted

Doesn't look good (source):

... GetFeatureInfo [...] is a WMS request and WFS. [...] One difference in their behaviour is that Geoserver sends always all the attributes with GetFeatureInfo but with WFS the list of attributes can be given in the request.

You could create a view that contains only the attributes your user wants to/should see and serve that through Geoserver.

An alternative would be to adjust die GetFeatureInfo template.

share|improve this answer
displaying or not displaying is one thing but radek want to return only some fields values. It makes a big difference regarding transfered data and security aspects. – simo Feb 10 '11 at 14:09
That's why my first suggestion was to create a view. – underdark Feb 10 '11 at 14:33
More on using VIEWs here. – radek Oct 10 '11 at 15:36

Just don't include the fields you don't want in your freemarker template. See

share|improve this answer
Good link, there is some real good documentation on the Geoserver site - This example I found useful (with a little fiddling around of course)for returning only the fields I wanted. – Ando Jun 30 '11 at 11:17

You can do this using the GeoServer propertyName WMS request parameter:

share|improve this answer

You can add conditional statements to freemarker templates.

For example in your content.ftl file you can add something like this to only list "YOUR_FIELDNAME".

     <li>${}: ${attribute.value}</li>

Alternatively you can exclude a field by doing this:

<#if ! == "YOUR_FIELDNAME">
     <li>${}: ${attribute.value}</li>
share|improve this answer

What about this?

Also, for this to return attributes (and not just the layer name and feature id) you have to add "ows_include_items" "attribute1, attribute2, ..., attributeN" or "ows_include_items" "all" to the metadata section of your WMS layer's map file entry.

From :

share|improve this answer
But Radek uses Geoserver, not UMN Mapserver, so there is no map file. – underdark Feb 10 '11 at 13:17
I've seen that. I've never used geoserver but I guess there is one way to set metadata as well, no? – simo Feb 10 '11 at 13:27

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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