当我使用此函数获取特征时,我发现:如果“特征”的“样式”(如图像和文本)在特征坐标的 100 像素范围内,则可以通过使用“特征”内的像素来获取特征风格'; 但是如果“样式”太远(超过 100 像素),我无法通过使用“样式”的像素来获得“特征”。
例如,将“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
})