I'm declaring and defining a geoJSON layer first, like:
var layer1 = L.geoJson(null, {
onEachFeature: function(feature, layer) {
...
}
});
..and then loading a CSV into it, like:
omnivore.csv('pbstatus.csv', null, layer1 )
.on('ready', function(e) {
...
});
Now, I want to create other geoJSON layers as subsets of layer1
based on the value of one of the CSV's columns loaded into the layer's feature.properties dataset. Is there a way to filter layer1
AFTER it's been defined and loaded? I'm aware of the 'proper' way of filtering when defining the layer:
var layer1 = L.geoJson(null, {
onEachFeature: function(feature, layer) {
...
},
filter: function(feature, layer) {
return (feature.properties.foo == 'bar');
}
});
.. but I don't want to repetitively do a different declaration each time. And, the data in the CSV is going to decide which layers and how many to form; we may not know all the possible filter conditions before we have imported the CSV. Is there a way I can spawn new layers as subsets of this layer1
after it's been loaded with geoJSON data ? Would the new layers also inherit the properties, actions and behaviours set in layer1
's onEachFeature:
function?