extract feature switching from onEachFeature to new func