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

Allow icon-image to accept a value that means "no icon-image" #6935

Open
nickidlugash opened this issue Jul 9, 2018 · 3 comments
Open

Allow icon-image to accept a value that means "no icon-image" #6935

nickidlugash opened this issue Jul 9, 2018 · 3 comments
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.)

Comments

@nickidlugash
Copy link

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

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

@nickidlugash nickidlugash added the cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.) label Jul 9, 2018
@ansis
Copy link
Contributor

ansis commented Jul 16, 2018

This sounds good to me. Should the empty string "" also be treated as "no image"? Should the empty string be a valid name (map.addImage("", image))?

@nickidlugash
Copy link
Author

Should the empty string "" also be treated as "no image"? Should the empty string be a valid name (map.addImage("", image))?

Regarding how this currently works, @jfirebaugh mentioned in chat the other day:

Theoretically you could have an empty ID in the spritesheet as well, and it would use that image. But I haven't tried this.

@ansis @jfirebaugh can you clarify: if we do (continue to) allow an empty string to be a valid sprite ID, would the only way to generate this sprite value be via gl-js (map.addImage("", image)) or our SDKs? AFAIK, you cannot create an svg with an empty string as the filename to upload via Styles API.

I can't think of any use cases for keeping an empty string as a valid sprite ID, but I don't have experience using our API/SDKs to generate sprite images.

@nickidlugash
Copy link
Author

@ansis @jfirebaugh Any further thoughts on whether we can/should implement this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cross-platform 📺 Requires coordination with Mapbox GL Native (style specification, rendering tests, etc.)
Projects
None yet
Development

No branches or pull requests

2 participants