Layer.isVisible()
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
**mapbox-gl-js version**: 2.8.2
### Question
I would like to know if my layer is visible
The layer is hidden according to the zoom in the map, is there a method to know the layers visible on the map ? I have tried to parse the array but is quiet complicated :/
The function `map.getLayoutProperty(layerId, 'visibility')` doesn't work because my layer is hidden with the zoom and not with an attribute
I would like to have a function like that :
`map.getLayer(id).isVisible() => boolean`
Thx
### Links to related documentation
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue points to map.getLayer(id).isVisible() and map.getLayoutProperty(layerId, 'visibility'); begin by reviewing those API paths and how zoom-based visibility is represented. Done means defining and implementing a way to determine whether a layer is currently visible at the map's zoom, with the behavior documented and tested.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- api, frontend, web-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100