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

Add option to collapse groups #20

Open
ccloquet opened this issue Feb 24, 2015 · 11 comments
Open

Add option to collapse groups #20

ccloquet opened this issue Feb 24, 2015 · 11 comments

Comments

@ccloquet
Copy link

Dear contributors,

I would find nice to implement some sort of collapsing of the groups. Here is how I did it quick and dirty with jqm :

if (!groupContainer) {
    [...]

    groupLabel.innerHTML = obj.group.name + "<span class='group-button' id='layers-group-"+obj.group.id+"'>&nbsp-</span>";

    container.appendChild(groupLabel);
    container.appendChild(groupContainer);

    [...]
}

At the end, added :

$('body').delegate('.group-button', 'click', function()
{
    var myid = $(this)[0].id
    console.log(myid)
    if ($("#"+myid).html() == "&nbsp;+")
    {
        $("#leaflet-control-"+myid).children().show()
        $("#"+myid).html("&nbsp;-")
    }
    else
    {
        $("#leaflet-control-"+myid).children().hide()
        $("#"+myid).html("&nbsp;+")
    }
})

Best regards,

@brentfraser
Copy link
Contributor

Interesting enhancement. I implemented the above code in v0.3.1 but the parent disappears as well as the children making it impossible to expand after a collapse.

@Asph91
Copy link

Asph91 commented Oct 29, 2015

Any news about this feature?

@ismyrnow
Copy link
Owner

I'm not planning to add this feature myself. If someone wanted to fork and add this functionality, I'd consider merging it.

It would need to be opt-in functionality (via advanced options), and not introduce any new dependencies, like jQuery. It would also need to play nicely with the layer group toggle functionality added by @brentfraser in v0.4.0.

@brentfraser
Copy link
Contributor

I really like the idea of this feature, so some requirements:

  • no new dependencies
  • use a graphic for the collapse/expand functionality (some kind of folder icon?)
    • as I recall, my group checkbox works on clicking anywhere on the group name so that would have to be changed...

@dosstx
Copy link

dosstx commented Dec 11, 2015

Please add this feature. I often have to deal with lots of feature categories and subcategories (100+) in my projects and need a way to consolidate all that in the control. For now, I'm reverting to css overflow:auto to allow scrolling, but it's messy.

@jerryhall
Copy link

Don't know if you've seen this but, here's a model that collapses: https://jsfiddle.net/gaby/La77L8L9/2/ which I'm not sure meets your dependency criteria. Thanks for your work on this as well!

@brentfraser
Copy link
Contributor

I like it (basemaps on the bottom of the list where they should be. WooHoo!). but it looks like only one category at a time can be expanded. I'll need to dig into it...

@grischard
Copy link

Apparently this fork does it. @tsrman, would you be interested in rebasing and doing a PR?

@tsrman
Copy link

tsrman commented Nov 28, 2016

Im litte bit busy for this time, i try create pull request on next week.

@Randy6668
Copy link

By any chance a working version of collapsible group be implemented? I've tried the for @grischard suggested, but there are no expanded layers beneath.

@hjrobinson
Copy link

hjrobinson commented May 27, 2018

Okay, so I used the fork, but the only way I can add polygons to the layer control (and avoiding a failed page load) is by extracting coordinates from a geoJSON file and adding them to into a polygon. I guess I could try to write a loop to convert the text, but is there a way to get L.geoJSON directly into the layer instead of using L.polygon?

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

No branches or pull requests

10 participants