vue-leaflet/Vue2Leaflet

Non-visible `l-layer-group` not being added to layer control

juventus18 opened this issue · 3 comments

Description

When adding a currently hidden overlay layer group, the group is not added to the layer control.

Live Demo

none

Steps to Reproduce

Add a layer group with current visibility set to false. i.e.:

<l-layer-group name="Targets" layer-type="overlay" :visible="false"></l-layer-group>

Expected Results

I expect the layer to be loaded in the Layer Control to be toggled on when desired.

Actual Results

Instead, the layer is never added to the map nor Layer Control, and thus, can never be "turned on"

Browsers Affected

  • Chrome
  • Firefox
  • Edge
  • IE 11
  • Safari 9
  • Safari 8

Versions

  • Leaflet: v1.5.21
  • Vue: v2.X.X
  • Vue2Leaflet: v2.5.2

Fix

I believe this is caused by a different implementation for adding the layer in the LLayerGroup component vs other components. In LLayerGroup it is added like this:

if (this.visible) {
  this.parentContainer.addLayer(this);
}

But other controls add the layer like this:

this.parentContainer.addLayer(this, !this.visible);

I don't really have a good way to test this right now... if one of the maintainers can implement the change, test, and make the PR, that would be great!

mikeu commented

Hi @juventus18 , thank you for this report and the detailed investigation! I should have time to take a look at that in the next few days here.

@DonNicoJs any idea when this will make it to release? Been a couple of months and I'd rather not have my package.json point to master. Thanks!

mikeu commented

Thank you for the reminder @juventus18, v2.7.1 was released a few days ago now, hopefully it resolves your issue!