我刚画了一个多边形并修改它。 如何在Open Layer 3中选择多边形时设置样式
感谢
答案 0 :(得分:0)
var selectClick = new ol.interaction.Select();
map.addInteraction(selectClick);
var sf =selectClick.getFeatures();
sf.on('add', addSelectionListener);
sf.on('remove', removeSelectionListener);
function addSelectionListener(){
var sf = selectClick.getFeatures();
sf.forEach(function(feature){
feature.setStyle(styles);
});
}
function removeSelectionListener(){
var sf = source.getFeatures();
sf.forEach(function(feature){
feature.setStyle(null);
});
}