3

I am trying to use WMS GetFeatureInfo request to popup display the feature/attributes of multiple WMS layers in OpenLayers. The problem is there too many attributes in each layer.

Is these any facility in GeoServer that allows me to expose only desired fields of a WMS layer when publishing it on GeoServer?

2
  • A WMS isn't a vector layer, a WMS may have a vector data source. Do you really mean WMS GetFeatureInfo and not WFS GetFeature?
    – nmtoken
    Apr 21, 2022 at 7:59
  • I am using getFeatureInfoUrl( ) to get the features in text/html format. My problem is that I don't want geoserver to send all the features/attributes of a layer.... I know I can use propertyName to get only the desired features, but I want to control which features to expose while publishing a layer on geoserver.
    – rss
    Apr 22, 2022 at 3:58

3 Answers 3

2

Wait for GeoServer 2.21 to be released, it has the ability to select fields, rename them (and even add new ones, based on expressions).

The release has been delayed a while due to the Log4J2 upgrade, but should be out before mid-May.

2

You can define what is in the GetFeatureInfo return using a template file.

Alternatively, you can make a request for JSON and only display the attributes you require.

1
  • I was using the JSON method when I had a few layers to query..now I am having multiple layers, I'll have to make separate JSON request for each layer...not efficient
    – rss
    Apr 21, 2022 at 12:20
1

You can specify the fields to be displayed by Geoserver during a GetFeatureInfo request by adding a parameter to the url in openLayers.

The parameter is propertyName.

ex: &propertyName=Field1,Field3, ...

Using this parameter, you can specify the name of the attributes to be shown.

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.