- 🇸🇰Slovakia sano
I am setting the Hit Tolerance to 200 and get the same result as when is it set to 0. Maybe something has changed between releases 7.x-3.2 and 7.x-3.3 that I am using?
- 🇸🇰Slovakia sano
It looks like the Hit tolerance functionality was removed in this commit.
I made the following change* to make this work (in the src/Plugin/Component/Popup/js/popup.js file). I replaced the old bit of code with the new one - see below.
The old code:
map.on('click', function(evt) { if ('getFeaturesAtPixel' in map) { // Introduced in v4.3.0 - new map.getFeaturesAtPixel() method. var features = map.getFeaturesAtPixel(evt.pixel); } else { // Replaced in v4.3.0 - forEachFeatureAtPixel() method replaced. features = []; map.forEachFeatureAtPixel(evt.pixel, function(feature) { features.push(feature); }); } var feature = undefined; if (features && features.length > 0) { for (item of features) { feature = item; } } });
The new code:
map.on('click', function(evt) { var hitTolerance = data.opt.hitTolerance || 0; if ('getFeaturesAtPixel' in map) { // Introduced in v4.3.0 - new map.getFeaturesAtPixel() method with hitTolerance. var features = map.getFeaturesAtPixel(evt.pixel, { hitTolerance: hitTolerance }); } else { // Replaced in v4.3.0 - forEachFeatureAtPixel() method replaced. features = []; map.forEachFeatureAtPixel(evt.pixel, function(feature) { features.push(feature); }); } var feature = undefined; if (features && features.length > 0) { for (item of features) { feature = item; } } });
* thank you ChatGPT :-)
- @sano opened merge request.