0

This is how I get feature info from a group layer when clicking on the map (using WMS GetFeatureInfo):

let view = this.map.getView()
let viewResolution = view.getResolution();
var source = this.groupLayer.getSource();

var url = source.getGetFeatureInfoUrl(
  this.map.getEventCoordinate(event), 
  viewResolution, 
  view.getProjection(), 
  {'INFO_FORMAT': 'application/json'}
);

this.expedientesService.getExpsClick(url).subscribe(exps => {
  console.log(exps)
})

The problem: This request is returning only one feature even if there are more than one on that clicked point.

The URL generated by getGetFeatureInfoUrl has the following format:

http://foo?
SERVICE=WMS&
VERSION=1.3.0&
REQUEST=GetFeatureInfo&
FORMAT=image%2Fpng&
TRANSPARENT=true&
QUERY_LAYERS=groupLayer&
LAYERS=groupLayer&
INFO_FORMAT=application%2Fjson&
I=50&
J=50&
CRS=EPSG%3Axyz&
STYLES=&
WIDTH=101&
HEIGHT=101&
BBOX=570384.8749920629%2C4722144.92875535%2C570386.7576818952%2C4722146.811445182

(I think I and J are always 50, don't know why)

As seen here If there is more than one feature at the point then it may return information about all the features (up to featureCount) that are there.

Any idea of what is wrong here?

I have an auxiliary layer containing all the features, and when making a WFS GetFeature request, multiple features are returned.

  • 3
    I do not see featurecount in the request. – user30184 Feb 25 at 7:58
  • You are right! I did just found that by default the number of features returned is 1. Thanks!! – Iñigo Feb 25 at 8:04
1

The problem was at the generation of the GetFeatureInfo URL. I didn't set the Feature_Count parameter, which sets the maximum number of features that can be returned. As seen here it is set to 1 by default.

I solved this problem adding the feature_count field as following:

var url = source.getGetFeatureInfoUrl(
  this.map.getEventCoordinate(evt), 
  viewResolution, 
  view.getProjection(), 
  {'INFO_FORMAT': 'application/json',
    'FEATURE_COUNT': '1000'}
);

Special thanks to @user30184 for his comment.

| improve this answer | |

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.