Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add Layer on non Leaf node #71

Open
ankitdhanai opened this issue Dec 8, 2023 · 5 comments
Open

How to add Layer on non Leaf node #71

ankitdhanai opened this issue Dec 8, 2023 · 5 comments

Comments

@ankitdhanai
Copy link

As per the documentation of the plugin 'Non leaf nodes (that is, those with children) can also have a layer. In this case you will be able to select the layer, and only the icon will collapse or expand this branch'

When I tried to add layer to non leaf node...then instead of one checkbox ..2 checkbox are rendering for that node....
please help...thanks in advance

@jjimenezshaw
Copy link
Owner

Providing a simple self contained example that reproduces it will help.

@ankitdhanai
Copy link
Author

ankitdhanai commented Dec 9, 2023

sdsdf

Below is the object that I am trying to add as inner child:
var innerchild = [{
label: 'France',
selectAllCheckbox: true,
layer: L.marker([52.9413240, 8.9581201]),
children: [{
label: 'Tour Eiffel',
layer: L.marker([48.8582441, 2.2944775])
},
{
label: 'Notre Dame',
layer: L.marker([48.8529540, 2.3498726])
},
{
label: 'Louvre',
layer: L.marker([48.8605847, 2.3376267])
},
],

        }, {
            label: 'Germany',
            selectAllCheckbox: true,
            children: [{
                    label: 'Branderburger Tor',
                    layer: L.marker([52.5162542, 13.3776805])
                },
                {
                    label: 'Kölner Dom',
                    layer: L.marker([50.9413240, 6.9581201])
                },
            ]
        }, {
            label: 'Spain',
            layer: L.marker([52.9413240, 8.9581201]),
            selectAllCheckbox: 'De/seleccionar todo',
            children: [{
                    label: 'Palacio Real',
                    layer: L.marker([40.4184145, -3.7137051])
                },
                {
                    label: 'La Alhambra',
                    layer: L.marker([37.1767829, -3.5892795])
                },
            ]
        }]

Below is the code of how I add above inner child to overlays:
overlaysTree = {
label: "Overlay Layers",
selectAllCheckbox: "Un/select all",
children: [{
label: "States",
selectAllCheckbox: "Un/select all",
children: innerchild
}, ],
};

I have also attached screenshot with red color marker on right ...

What I am trying to achieve :
Lets take example of airports of your docs...
Suppose user selects Germany checkbox then polygon shape must appear on map for Germany ...and all the airports in Germany must be displayed as point ....and user can select and unselect any of these airports for displaying on map.

The problem of two checkbox is occurring when I set selectAllCheckbox option true for Germany and if I do not provide any selectAllCheckbox option then single checkbox is appearing for Germany but on selecting it...it is not selecting checkbox of all the airports in Germany.

However when I provide selectAllCheckbox true for germany the second checkbox is working as per my need but first checkbox is also appearing which is working independently that is when I select first checkbox all the airports in Germany are not getting selected .

Thanks

@ankitdhanai
Copy link
Author

Have you looked into this issue? Thanks

@jjimenezshaw
Copy link
Owner

No, sorry, I had no time. I cannot ensure that I will have time in the near future.
What I remember is that the checkboxes feature was added much later than the non-leaf with layer. Probably I never tested checkboxes in a non-leaf node with a layer.
One explanation could be that there are two checkboxes, one for the non-leaf layer itself, and another to control the children.
... but do you really need a layer in that non-leaf node?

@ankitdhanai
Copy link
Author

Sorry...but yes....I need layer in non leaf node...thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants