Vue2leaflet: this.parentContainer.hideLayer doesn't work

Created on 6 Jan 2020  路  3Comments  路  Source: vue-leaflet/Vue2Leaflet

this.parentContainer.hideLayer doesn't work

Browsers Affected

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

Versions

  • Leaflet: v1.6.0
  • Vue: v4.0.5
  • Vue2Leaflet: v2.4.1
bug confirmed

Most helpful comment

@DonNicoJs Something is wrong.

<l-map>
  <l-layer-group ref="gridImageLayerGroup" :visible="gridImageLayerGroup.visible">
        <l-layer-group ref="gridImageLayer" :visible="gridImageLayer.visible"/>
        <l-layer-group ref="gridValueLayer" :visible="gridValueLayer.visible"/>
      </l-layer-group>
</l-map>

When I set gridImageLayerGroup.visible = false, the gridImageLayer and gridValueLayer are still show.
I find this reason is that :
in LMap.vue

 hideLayer(layer) {
      if (layer.layerType !== undefined) {
        this.mapObject.removeLayer(layer.mapObject);
      }
    },

Lmap's layerType is undefined. So it doesn't work!

All 3 comments

@DonNicoJs Something is wrong.

<l-map>
  <l-layer-group ref="gridImageLayerGroup" :visible="gridImageLayerGroup.visible">
        <l-layer-group ref="gridImageLayer" :visible="gridImageLayer.visible"/>
        <l-layer-group ref="gridValueLayer" :visible="gridValueLayer.visible"/>
      </l-layer-group>
</l-map>

When I set gridImageLayerGroup.visible = false, the gridImageLayer and gridValueLayer are still show.
I find this reason is that :
in LMap.vue

 hideLayer(layer) {
      if (layer.layerType !== undefined) {
        this.mapObject.removeLayer(layer.mapObject);
      }
    },

Lmap's layerType is undefined. So it doesn't work!

have same issue, my quick fix was to set layerType to some value (e.g. "LMarker") on the components.
I guess someone forgot to set default values for the components...

@hoticer @JohnnyAW I've addressed the issue and publish a new patch version.
I need absolutely to focus on:

  • docs
  • ci
  • tests

Apologies for the very slow update

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lusman20 picture lusman20  路  4Comments

mits87 picture mits87  路  3Comments

udos picture udos  路  4Comments

RemiDesgrange picture RemiDesgrange  路  5Comments

mpallante picture mpallante  路  4Comments