82
社区成员
发帖
与我相关
我的任务
分享今天一个GIS技术人员加我微信(gis-dajianshi),问了个问题。 他在feature添加文字样式后,随着zoom的放大缩小,文字一会显示,一会消失。

后来我查了一下API,需要在text部分添加overflow:true, 即可以解决。

feature.setStyle(function(feature){
return new Style({
stroke: new Stroke({
width: 1,
color: [255, 0, 0, 0.8]
}),
fill: new Fill({
color: [0, 0, 255, 0.6]
}),
text: new Text({
text: item.name,
overflow:true,
fill: new Fill({
color: '#fff'
})
})
})
})