-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Add expression operator to determine style image availability #5261
Comments
With an eye towards future introduction of expression forms that combine, lighten, darken, recolor, or otherwise manipulate images, I would design this slightly differently, providing an |
Would properties like |
Moving If we were to introduce a |
Tangentially, #5775 exposes a |
Since my original work on conditional images in baf963b and 471f003, @ChrisLoer came up with two suggestions for plumbing this information through to
/cc @nickidlugash |
@1ec5 @ChrisLoer @jfirebaugh @anandthakker @lucaswoj This feature is still something that the cartography team would find valuable to have implemented and available in our APIs and SDKs by mid Q2 2018 (which I'm assuming will be far in advance of any larger style spec image refactors). The most critical gain for us would be flexibility in when we can add additional values to maki (POI), highway shield, and rail station fields in the Mapbox Streets vector tiles. Without the ability to look up image existence in sprites, all icon value additions are considered a breaking change and can only be added at major version bumps. If this feature is not available by the time we release Streets v8, we will not be able to support any additions for at least a year after. This could be potentially concerning if there are critical regional markets that customers need added support for. From a style spec perspective, does it makes sense to add this feature now (before other image refactors)? Please let me know if I can help further scope how this feature might be used, either to help decide whether we can more forward with this now or to help determine the best method for implementation. |
By the time mapbox-gl-js/src/source/worker_tile.js Lines 139 to 145 in 6997943
|
This (#5261 (comment)) is a valuable addition that could have broad applicability. We've discussed its utility in icon fallbacks in this ticket and #8052 (comment), and it could also be used to support composing multiple images together as a single We should consider how to handle the interaction between an In a chat with @ansis, we discussed a few options:
I'm comfortable with option A as I think firing the event is fairly cheap and don't foresee huge issues with it, though it would be nice if it were possible to gather data on the question. If we're nervous about always firing the event, I prefer option B over C, which introduces unnecessary complexity. The main con to option B is a general hesitation around introducing additional objects to an operator with broad applicability. We don't want to get into the habit of bloating cc @1ec5 @alexshalamov @mapbox/gl-js @mapbox/gl-native @mapbox/maps-ios @mapbox/maps-android |
also cc @samanpwbb @tristen @mapbox/map-design-team |
A or B both sound ok but if we can get away with A, definitely prefer that for the reasons you mentioned above. I believe that, with #8052 (comment), many use cases for |
To add to what @samanpwbb said, I think the expression-based fallback should be treated separately from the "styleimagemissing" callback to a certain degree. That is to say that - an image is missing and emits the event if it is the final image resolved from an expression and is still not found (not if it resolves to Applications that rely on
As far as option A is concerned - always firing the event can be misleading. We have documented that calling |
@asheemmamoowala, am I interpreting your comment correctly: you're saying you prefer a separate option
because
so we don't need to fire it with each I have two responses to that: The It's safe to say that we will have new icon features for which firing the callback on Moreover, I thought of a use case for using
You'd want to be able to provide the branded icon to the map on-demand so that you don't need to change your map/sprite implementation at all as your partnerships change. Further, it would be impractical to add all branded icons on the spritesheet, as you may eventually run up against our sprite limit.
Great questions, we should investigate the technical feasibility of these designs on JS and Native. The intention is that the developer should be able to provide a missing image via |
ah, earlier tonight I realized it doesn't make sense to fire Still not sure whether you're overall for firing the |
Originally I wanted to keep this ticket open to house discussion about an |
This operator was implemented in #8684 |
The style specification should have an
image-exists
orhas-image
operator for use in expressions. It would accept one argument, the name of an image, and return a Boolean indicating whether the image is part of the style (e.g., viaaddImage()
). Typically, this operator would be used inside acase
operator.This operator would allow style designers to significantly condense any symbol layers that display route shields using the Mapbox Streets source by no longer hard-coding a list of known
shield
values: #4149 (comment). It would also future-proof those layers for any additionalshield
values that we would add to the source down the line; currently such changes are breaking changes because the hard-coded list has no fallback mechanism.An
image-exists
operator would be more flexible than the “image stacks” proposed in #4149: it could be used on any property, not only an image-typed property. The existence of an image with a given name could determine not only the icon to display but also the color of the text to superimpose. A designer would still need to employ the-white
hack described at the bottom of #4149 (comment) until we get a substring expression operator (#4113), but at least the long and fragile list would go away and we’d be able to use a single layer for both black- and white-lettered shields.For context, a shield fallback was a key use case that led to the implementation of expressions in the first place: mapbox/mapbox-gl-style-spec#104 (comment). In #4715 (comment), we decided to punt on this use case for the initial PR that implemented expressions.
/cc @anandthakker @jfirebaugh @mapbox/cartography
The text was updated successfully, but these errors were encountered: