Allow `icon-image` to accept a value that means "no icon-image"
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 12.4k
- Forks
- 2.4k
- PR merge metrics
- No merged PRs in 30d
Description
## Motivation
Right now, if you don't want to include an icon for a symbol layer, you simply don't assign an `icon-image` value. However, there are situations where you want to assign an expression value for `icon-image` that includes a "no icon image" assignment for just some zoom levels or some conditions.
## Design Alternatives
- Use `icon-opacity` to control visibility of icons within a style layer (which is what we currently do in our core styles).
- Assign an empty string (`""`). However, this will be treated like any other string that doesn't exist in the spritesheet (i.e. will soon throw a warning, per https://github.com/mapbox/mapbox-gl-js/issues/6823).
## Design
Per conversation with @jfirebaugh, perhaps it would make sense to special case `null` values to mean "no icon image" (the alternative perhaps being to special case empty strings). Currently, `icon-image` will not accept null values.
### Mock-Up
Example expressions:
```
"icon-image": [
"step",
["zoom"],
"dot-11",
8,
null
]
```
```
"icon-image": [
"case",
["has", "text_anchor"],
"dot-11",
null
]
```
### Concepts
> Where do the concepts set new precedents?
Using `null` values to represent "no icon" is different to how `text-field` works, which accepts (and defaults to) empty strings to mean "no text".
### Implementation
Not sure what the critical implementation considerations are for this.
/cc @mapbox/gl-core @mapbox/maps-design @mapbox/studio
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 names no file or test; start by searching the repository for icon-image handling and expression validation. Done means the documented null expressions are accepted and result in no icon at the specified zoom level or condition, with regression coverage for both examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend, web-dev
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100