question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add recursive to L.LayerGroup.eachLayer()

See original GitHub issue

It might be useful to add an new option to L.LayerGroup.eachLayer() method for recursive behavior? This could greatly improve management and research possibilities on complex data.

for example:

....geojson loading...

var geo1 = L.geoJson(Geo1);
var geo2 = L.geoJson(Geo2);
var geo3 = L.geoJson(Geo3);
var geo4 = L.geoJson(Geo4);

var group1 = L.LayerGroup([geo1, geo2]);
var group2 = L.LayerGroup([geo3, geo4]);
var groupAll = L.LayerGroup([group1, group2]);

groupAll.eachLayer(function(lay, layParent) {
   console.log(lay, layParent);
}, {
 recursive: true
//new option
})

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
Dominique92commented, Nov 4, 2016

I propose something like:

L.LayerGroup.include({
    eachLayerRecursive: function(method, context) {
        this.eachLayer(function(layer) {
            if (layer._layers)
                layer.eachLayerRecursive(method, context);
            else
                method.call(context, layer);
        });
    }
});

Run method on all LayerGroup tree leaves but not on branches.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Leaflet - tell whether an object a layer or a group
L.LayerGroup can contain other LayerGroups, pretty confusing. I made this generic solution for recursively traversing a layergroup in ...
Read more >
L.LayerGroup
Iterates over the layers of the group, optionally specifying context of the iterator function. group.eachLayer(function (layer) { layer.bindPopup('Hello'); });.
Read more >
adding layers in layer group dynamically to layer control in ...
In your ajax callback, you should find layerGroup = L.layerGroup() .addLayer(vector1)) .addLayer(vector2)) .addLayer(vector3)) .
Read more >
Computing Receptive Fields of Convolutional Neural Networks
Each layer l l 's spatial configuration is parameterized by 4 ... This equation can be used in a recursive algorithm to compute...
Read more >
16. Trees 3: Construction of Dynamic Binary Trees
Layer structure; Data for nodes; Fill for "missing" nodes ... RClone() is a recursive method (and private) method that builds a deep copy...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found