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

QGIS layers within layer groups with visibility=false cannot be displayed #23

Open
amuedespacher opened this issue Jan 17, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@amuedespacher
Copy link
Contributor

amuedespacher commented Jan 17, 2024

If a QGIS project has a layer group set to visible==false, setting the visibility of the individual layers to true in QGIS-js does not render the layers on the map.

Steps to reproduce:

  • Create a QGIS project
  • Create a layer group with at least one layer, and set it to invisible (via the checkbox in the layer list)
  • Open the QGIS project with QGIS-js (e.g. on demo site)
  • Try to switch on the layer that is in the group

Actual result:

  • Layer is not displayed on the map

Expected result:

  • Layer is displayed on the map

Example:
(last two layers should render a choropleth map)
qgis-js-invisible_layers

@amuedespacher amuedespacher changed the title QGIS layers with initial visible==false cannot be rendered QGIS layers with initial visibility==false cannot be rendered Jan 17, 2024
@amuedespacher amuedespacher changed the title QGIS layers with initial visibility==false cannot be rendered QGIS layers within layer groups with visibility=false cannot be displayed Jan 18, 2024
@amuedespacher
Copy link
Contributor Author

I did some more testing, and the issue can be narrowed down to more specific cases, where layer groups are used. I updated the description of the issue accordingly.

@boardend boardend added the bug Something isn't working label Jan 20, 2024
@boardend
Copy link
Collaborator

The problem is that itemVisibilityChecked() and setItemVisibilityChecked() in MapLayer.hpp will only effect the layer but not it's parent elements, see https://api.qgis.org/api/classQgsLayerTreeNode.html

I did a quick test switching to isVisible() and setItemVisibilityCheckedParentRecursive() which helps to actually show the layer as not visible and to be able to set the invisible group to visible. But will then also make the whole group invisible when just one layer should be set to invisible.

The whole MapLayer implementation was just a quick shot to get a basic example working (without thinking about groups at that point). IMHO the only sane solution is to actually expose the QGIS internals: QgsLayerTree, QgsLayerTreeModel, QgsLayerTreeNode, QgsLayerTreeGroup, QgsLayerTreeLayer. And then build a hierarchical layer widget on top of that.

I've created a new issue for that, see #25

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants