Is there a way to replicate the behavior of L.LayerGroup.eachLayer() with GridLayer? I'm using Leaflet.VectorGrid (L.VectorGrid.Slicer) in order to wrap some GeoJSON around the world, and I'd like to add each feature to one or more layer groups. For example, the code below for GeoJSON objects works, but not for grid layers.
// want to do something like this; layer groups defined previously
L.geoJSON(usData, {
style: // styling logic
})
.eachLayer(layer => {
layerGroup1.addLayer(layer);
if (category2.indexOf(layer.someProperty) !== -1) {
layerGroup2.addLayer(layer);
}
if (category3.indexOf(layer.someProperty) !== -1) {
layerGroup3.addLayer(layer);
}
})
.addTo(mapObject);
// no eachLayer() method for grid layers or slicers; how could you do this with grid layers?
L.vectorGrid.slicer(usData, {
vectorTileLayerStyles: {
sliced: properties => someFunction(properties)
},
interactive: true
})
.eachLayer(layer => {
// do something with each layer
})
.addTo(mapObject);