walkermatt / ol-layerswitcher

Layer control for OpenLayers
MIT License
384 stars 176 forks source link

Collapse, strange behaviour. #439

Closed AllroadsNL closed 3 years ago

AllroadsNL commented 3 years ago

The red section does not show the grouplayers like the blue section.

grouperror The first four on the bottom working correctly, the red section not.

It looks like when there more then 4 overlay it gives a strange behaviour.

Is there a limit?

Using openlayers /v6.5.0/ ol-layerswitcher@3.8.3

set to groupSelectStyle: 'children'

` // Show layerlist

var layerSwitcher = new ol.control.LayerSwitcher({
    activationMode: 'click',
    tipLabel: 'Show layer list',
    collapseTipLabel: 'Hide layer list',
    groupSelectStyle: 'children'
    });
map.addControl(layerSwitcher);`

10 overlaygroups is in the "var map"

overlayGroup, overlayGroup1, overlayGroup2, overlayGroup3, overlayGroup4, overlayGroup5, overlayGroup6, overlayGroup7, overlayGroup8, overlayGroup9,

when I only use 5 layer groups I still have the problem with overlayGroup4

` }), overlayGroup, overlayGroup1,
overlayGroup2, overlayGroup3, overlayGroup4,

    ],`

group 3 and 4 are similair.

var overlayGroup3 = new ol.layer.Group({ title: 'Overlays AHN 3 (2014-2019) OSMOK met <a href="https://forum.openstreetmap.org/viewtopic.php?pid=649579#p649579" target="_blank">ESRI NL individuele licentie</a>', // Adding a 'fold' property set to either 'open' or 'close' makes the group layer // collapsible fold: 'open', layers: [ ] }); var overlayGroup4 = new ol.layer.Group({ title: 'Opacity overlayers, BGT, OSMOK o.b.v. afspraak met <a href="https://forum.openstreetmap.org/viewtopic.php?id=59021" target="_blank"> Min. BZK, Kadaster</a> (CC BY 4.0)', // Adding a 'fold' property set to either 'open' or 'close' makes the group layer // collapsible fold: 'open', layers: [ ] });

I did not set "combine" on overlayGroups

I use the "overlayGroup4.getLayers().push(" method to set the layers.

First I have a page with openlayers 5.3.0 and layerswirtcher 3.0.0. This gave me all the layers. As expected. I did not change the layers push.

ol5group

walkermatt commented 3 years ago

Hi, Do you have a link to your app so I can take a look in more detail? It looks as though the groups in the red section don't contain any layers but it's hard to tell.

I'm not aware of any limits.

AllroadsNL commented 3 years ago

The mistake, ..... In overlayGroup4 layers I have one: visible: true, with opacity:'0.55',

In OL 5 that was not a problem. It also did not give a OL error (firefox web development / console), layerswitcher tree worked. but in OL 6 it gives a error 64

64 Layer opacity must be a number.

when I set it to

opacity: 0.55,

The tree is now working fine.

At the same time I switched to using openlayers /v6.5.0/ ol-layerswitcher@3.8.3 and change the tree method.

Sorry for this mistake.

walkermatt commented 3 years ago

Thanks for the update, glad you sorted it 😃