I just drawn a polygon and modifying it. How to set style on selection of polygon in Open layer 3
thanks
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);
});
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.