2016-04-21 60 views

回答

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); 
}); 
}