Currently the groups and layers seem to be ordered arbitrarily in the control panel. It would be nice to preserve the order from the group definition or specify the order via a flag.
Can you provide an example? Does it behave similarly with the built-in control?
I render the layers almost exactly how the built-in layer control does it, for consistency. If their control has a bug in this area as well, it may be worth fixing in both places.
Hi there, i prob won't find the time to put together an example, but i did check the leaflet layer control works fine, it was only an issue in the grouped control, because of the grouping.
Here's the issue I'm having: http://jsfiddle.net/wzLp4/. This is your example but I switched the order of Cities (1) and Motorways (2) layers in the groupedOverlays yet they show up as Motorways (1) and Cities (2). Do I have the wrong expectation as to how layers will be ordered? Based on some trials I've done this may be related to Leaflet.
@mjigmond take a look at this modified fiddle: http://jsfiddle.net/ismyrnow/wzLp4/1/
The only difference is the order the layers are added to the map (not the layer control). This behavior is also exhibited by Leaflet's layer control.
I would love to get this fixed, and even submit a pull request to Leaflet if it makes sense, since this seems like a bug to me as well. I doubt I'll have time to fix this, but I'll accept a pull request.
I believe the issue lies around line 115, where the layer is given a unique ID. Leaflet's control does it the same way, but I believe this is what's causing the strange behavior.
The problem (for me anyway) is that I don't want all layers to be enabled on page load. So if I want just one overlay out of ten to be enabled, that overlay will always be first in the list even if I want it at the bottom of the list (http://jsfiddle.net/wzLp4/2/). I'm more of a user than a developer and never really dissected one of these libraries but I'll take a look. I'll also look through the issues raised on Leaflet regarding layer ordering. Thanks for taking a look. For my purposes your plugin is great once I solve the ordering.