Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 这是getFeaturesAtPixel(pixel,opt_选项)的错误吗?_Javascript_Openlayers_Openlayers 6 - Fatal编程技术网

Javascript 这是getFeaturesAtPixel(pixel,opt_选项)的错误吗?

Javascript 这是getFeaturesAtPixel(pixel,opt_选项)的错误吗?,javascript,openlayers,openlayers-6,Javascript,Openlayers,Openlayers 6,当我使用此函数获取功能时,我发现: 如果“特征”的“样式”(如图像和文本)在特征坐标的100像素范围内,我可以使用“样式”内的像素获得特征; 但是如果“样式”太远(超过100个像素),我就无法通过使用“样式”的像素来获得“特性” e、 g.将“ol/style/Text”添加到特征的样式中 new Text({ font: '15px Microsoft YaHei', text: '', fill: new Fill({ color: '#222' }), back

当我使用此函数获取功能时,我发现: 如果“特征”的“样式”(如图像和文本)在特征坐标的100像素范围内,我可以使用“样式”内的像素获得特征; 但是如果“样式”太远(超过100个像素),我就无法通过使用“样式”的像素来获得“特性”

e、 g.将“ol/style/Text”添加到特征的样式中

new Text({
  font: '15px Microsoft YaHei',
  text: '',
  fill: new Fill({
    color: '#222'
  }),
  backgroundStroke: new Stroke({
    color: 'rgba(0,0,0,0.5)',
    width: 1
  }),
  backgroundFill: new Fill({
    color: 'rgba(0,250,154,0.3)'
  }),
  textAlign: 'middle',
  textBaseline: 'middle',
  offsetX: 200,
  offsetY: 200
})

我在github中找到了解决方案:
默认情况下,OpenLayers只考虑命中检测功能周围100像素的区域。当使用200像素的偏移量时。你不在那个地区。若要修复此问题,请使用大小合适的
renderBuffer
配置图层。

是否尝试了
hitTolerance
选项?@Anatoly是的,但重点是另一个问题。大的
命中容差
可以使命中范围更大的功能。