Javascript 这是getFeaturesAtPixel(pixel,opt_选项)的错误吗?
当我使用此函数获取功能时,我发现: 如果“特征”的“样式”(如图像和文本)在特征坐标的100像素范围内,我可以使用“样式”内的像素获得特征; 但是如果“样式”太远(超过100个像素),我就无法通过使用“样式”的像素来获得“特性” e、 g.将“ol/style/Text”添加到特征的样式中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
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是的,但重点是另一个问题。大的命中容差
可以使命中范围更大的功能。