[GIS] OpenLayers 4 getGetFeatureInfoUrl and HitTollerance

javascriptopenlayers

I'm using this piece of code

map.on('singleclick', function(evt) {

...
url = pmfeatlayer.getSource().getGetFeatureInfoUrl(coordinate, viewResolution, projection, {'INFO_FORMAT': 'text/html'});

if (url) {...
}
...
}

And here my layer:

pmfeatlayer = new ol.layer.Tile({
  extent: ext,
  preload: Infinity,
  source: new ol.source.TileWMS({
    url: Settings.url,
    params: {'LAYERS': sQLayers, MYORDERS: Settings.order, DTO: DTo, format: 'image/png'},
    ratio: 1.1,
    gutter: 40
  })
});

to get the feature info on pmfeatlayer, Inside all the code I have also a function that displays a list of the feature in that pixel (If I have more than 1 URL create a list of them)

How can I increase the tolerance?

I found this example but I can't get it work, is this just for features or also for layers?

https://openlayers.org/en/latest/examples/hit-tolerance.html

Here a screenshot of my map.

enter image description here

I have a map layer and a featlayers (all the street restriction are on that layer) and as you can see from the popup at that pixel I have 2 restrictions, how can I increase the radius o get also the 2 street sign for example (because at the moment he display the 2 street line but not the signs)?

Best Answer

WMS getFeatureInfo sends a single XY coordinate. The receiving server could apply a buffer. For GeoServer, you can use the buffer vendor specific paramter

url = pmfeatlayer.getSource().getGetFeatureInfoUrl(coordinate, 
         viewResolution, 
         projection, 
         {'INFO_FORMAT': 'text/html','buffer':'10'}
      );
Related Question