-
Notifications
You must be signed in to change notification settings - Fork 38
“Image stacks” for image properties #597
Comments
Can you say more about the rationale for this feature? Why is it useful? |
Map designer POV: Say I want to make a set of totally custom icons for my map but still take advantage of the Mapbox Streets vector tile maintainer POV: right now adding new values to fields like |
Along these lines, a style designer currently needs to jump through a lot of hoops to implement highway shields. The Mapbox Streets source’s {
"id": "road-shields-black",
"type": "symbol",
…
"filter": [
"all",
[
"<=",
"reflen",
6
],
[
"!in",
"shield",
"at-expressway",
"at-motorway",
"at-state-b",
"bg-motorway",
"bg-national",
"ch-main",
"ch-motorway",
"cz-motorway",
"cz-road",
"de-motorway",
"e-road",
"fi-main",
"gr-motorway",
"gr-national",
"hr-motorway",
"hr-state",
"hu-main",
"hu-motorway",
"nz-state",
"pl-expressway",
"pl-motorway",
"pl-national",
"ro-county",
"ro-motorway",
"ro-national",
"rs-motorway",
"rs-state-1b",
"se-main",
"si-expressway",
"si-motorway",
"sk-highway",
"sk-road",
"us-interstate",
"us-interstate-business",
"us-interstate-duplex",
"us-interstate-truck",
"za-metropolitan",
"za-national",
"za-provincial",
"za-regional"
]
],
"layout": {
…
"icon-image": "{shield}-{reflen}",
…
"text-field": "{ref}",
…
},
…
}, And another one like it for shields with white text. This filter has to be kept in sync with the list of possible values. This proposal would simplify that layer dramatically: {
"id": "road-shields-black",
"type": "symbol",
…
"filter": [
"all",
[
"<=",
"reflen",
6
],
[
"has",
"shield"
],
],
"layout": {
…
"icon-image": [
"{shield}-{reflen}-black"
"generic-{reflen}-black"
],
…
"text-field": "{ref}",
…
},
…
}, (This example would require |
The implementation for this feature in GL JS would look very similar to the 1ec5-token-selection-104 branch (which is a proposed implementation of #104), but more tightly scoped so that non-image fields are unaffected by the changes. For simplicity’s sake, we’d continue to represent tokens with the |
This issue was moved to mapbox/mapbox-gl-js#4149 |
The image properties –
background-pattern
,fill-extrusion-pattern
,fill-pattern
,line-pattern
,icon-image
– should accept an array of strings as an alternative to a single string. As withtext-font
’s “font stack”, the renderer should loop over the items of the array, selecting the first value that corresponds to a valid image in the style. Tokens in each item should be evaluated as they are now. Studio would provide a UI foricon-image
very similar to the UI fortext-font
:This is an alternative to the “token-selection” syntax proposed in #104 (comment). Unlike the other use cases being discussed in #104, selecting an image is special because it is the evaluated string as a whole that must be tested for validity, not an individual token with the string. Any syntax we eventually introduce for conditionals or token defaults would coexist with the image stack syntax.
/cc @mapbox/cartography-cats @mapbox/gl
The text was updated successfully, but these errors were encountered: