1

I am using GetFeatureInfo to create a popup for different layers and features in a map in Leaflet. I have up to 3 layers that can be visible and overlapping at any given time. If I put the option "feature_count=3" in my request to GeoServer it works great with the exception of when I am zoomed out and features are very small. When this happens and only one layer is visible I will often get 3 results in the popup for that layer. It seems that since the location I click on might refer to more than one feature in a layer, it returns three features for that layer. I have different code that inserts only visible layers into the code below.

How do I ensure that when clicking the map, only one feature's info per layer is returned in the popup? I wish the "feature_count" option referred to how many features to return per layer.

'http://xx.xx.xx.xx/geoserver/workspace/wms?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetFeatureInfo&LAYERS=layer1,layer2,layer3&QUERY_LAYERS=layer1,layer2,layer3&STYLES=&BBOX='+BBOX+'&HEIGHT='+HEIGHT+'&WIDTH='+WIDTH+'&FORMAT=image%2Fpng&INFO_FORMAT=text%2fhtml&SRS=EPSG%3A4326&feature_count=3&X='+X+'&Y='+Y+''

Is there an option in GeoServer that I am missing or an option in my code? Do I have to generate a different link like the one above for each layer?

  • Have you tried &maxFeatures=1 parameter? – artwork21 Dec 21 '16 at 18:31
4

Yes, you have to generate one request per layer with FEATURE_COUNT=1 in each.

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.