我需要能够样式的地图上的要素后,他们已经渲染了每个用户的选择。
目前我正在添加这样的样式...
style: function (feature, resolution) {
var text = resolution * 100000 < 10 ? response.text : '';
if (text != "") {
styleCache[text] = [new ol.style.Style({
stroke: new ol.style.Stroke({
color: '#319FD3',
width: 1
}),
text: new ol.style.Text({
font: '12px Calibri,sans-serif',
text: text,
fill: new ol.style.Fill({
color: '#000'
}),
stroke: new ol.style.Stroke({
color: '#fff',
width: 3
})
}),
fill: new ol.style.Fill({
color: colorFromDatabase
})
})];
}
else if (text == "") {
styleCache[text] = [new ol.style.Style({
fill: new ol.style.Fill({
color: colorFromDatabase
})
})
]
} return styleCache[text];
}...I需要能够进入并更改填充、笔触等。渲染后,我已经有了有限的“成功”...if,这就是你想要称之为it...making所有功能的黑色。
非常感谢您的帮助!
发布于 2016-09-21 00:12:36
谢谢@Jonatas Walker在你的帮助下我最终得到了这个...
var source = webLayer.getSource();
var features = source.getFeatures();
var templateStyle = new ol.style.Style({
fill: new ol.style.Fill({ color: convertHex(Layer.LayerStyle.FillColor, '0.5') }),
stroke: new ol.style.Stroke({ color: convertHex(Layer.LayerStyle.LineColor, '0.5') }),
text: new ol.style.Text({
font: '24px Verdana',
text: webLayer.U.label,
offsetY: 20,
fill: new ol.style.Fill({
color: [255, 255, 255, 0.8]
})
})
});
var select = new ol.interaction.Select({
style: templateStyle
});
map.addInteraction(select);
webLayer.setVisible(Visibility);
features[0].setStyle(templateStyle);这就是应用样式!!
https://stackoverflow.com/questions/39532949
复制相似问题