Openlayers 3 forEachFeatureAtPixel 不能正常工作点

Openlayers 3 forEachFeatureAtPixel doesn't work correctly for Points

我需要使用 OpenLayers 3 实现 "click on feature" 功能。它适用于所有类型的功能,但是当使用 "Point" 时,当我点击离中心足够远(足够接近到边界)。我在这里创建了一个示例 - https://jsfiddle.net/mstrop/4gvLhfje/7/

var pixel = map.getEventPixel(evt.originalEvent);   

var found = false;

map.forEachFeatureAtPixel(pixel, function(feature, layer) 
{
    found = true;
});

console.log((found?"":"not ") + "found");

当您开始单击边框并继续向圆心移动时,您会看到圆离边框很远。拜托,有人能告诉我,我做错了什么吗?

改变

var pixel = map.getEventPixel(evt.originalEvent);   

var pixel = evt.pixel;   

您正在寻找这个:

map.on('click', function(evt) {
  var feature = map.forEachFeatureAtPixel(evt.pixel, function(ft){return ft;});
  if (feature) {
    // ...
  }
});

点几何的问题是 "hidden" 在 属性 中。它使用 renderBuffer,默认为 100px。如果几何半径较大,则必须手动增加 属性。