var nonTextStyle = new ol.style.Style({
//把点的样式换成ICON图标
fill: new ol.style.Fill({
//填充颜色
color: 'rgba(37,241,239,0.2)'
}),
//图形样式,主要适用于点样式
image: new ol.style.Circle({
//半径大小
radius: 7,
//填充
fill: new ol.style.Fill({
//填充颜色
color: '#e81818'
})
}),
text: new ol.style.Text({
// 字体与大小
font: '13px Microsoft YaHei',
//文字填充色
fill: new ol.style.Fill({
color: '#666'
}),
//文字边界宽度与颜色
stroke: new ol.style.Stroke({
color: '#fff',
width: 3
}),
// 显示文本,数字需要转换为文本string类型!
/*text: "" + vectorSource.features.values_.limitvalue + "",*/
offsetY: -15
})
});
vector = new ol.layer.Vector({
source: vectorSource,
/*style: nonTextStyle,*/
style: function (feature) {
var limitvalue = feature.values_.limitvalue;
if (limitvalue != null && limitvalue != undefined && limitvalue > 0) {
nonTextStyle.getText().setText("" + limitvalue + "");
}
return nonTextStyle;
},
name: nodeArray[i][1],
visible: false,
id: nodeArray[i][0],
zIndex: 1000,
updateWhileAnimating: false,
updateWhileInteracting: false
});
OpenLayers设置显示文本
最新推荐文章于 2024-02-28 09:23:32 发布