Description
Hello! Most of the action around data-driven styling is now happening in #1932
Implementing data-driven styling is as easy as 1-2-3-4-5-6-7-8
1. Refactor Buffer
to design buffer layouts at runtime
Status 🚢
merged in #1526
2. Refactor Bucket
to seperate the calculation of each attribute
We are going to implement data-driven styling using disableable shader attributes. This refactoring implements an abstraction that will allow us to turn on and off attributes and use the same logic to calculate an attribute, whether it is disabled or enabled.
Status 🚢
merged from #1620
3. Change shader uniform
s to attribute
s
In order to supply per-feature values to WebGL, we need to convert some shader uniform
s to attribute
s.
This could be challenging because, as we saw in #1336, IE has a big performance penalty for using a disabled attribute instead of a uniform.
Status 💭
previously implemented in #1257 but reverted in #1418 because of #1336
now tracked in #1714
4. Add support for data-driven styles in mapbox-gl-style-spec
Status 🚢
in pull request at mapbox/mapbox-gl-style-spec#399
5. Add support for data-driven styles in mapbox-gl-function
merged in mapbox/mapbox-gl-function#2, overhauled in mapbox/mapbox-gl-function#12
Status 🚢
6. Get mapbox-gl-js
running on mapbox-gl-function
v2
depends on 5
Status 🚢
7. Create layer classes
We should create a class per layer type (i.e. LineLayer
, CircleLayer
, FillLayer
, ...) like we did in mapbox-gl-native. In the long run, these classes should encapsulate all layer-specific operations, including drawing, bucket building, etc. For data-driven styling, these classes need to be able to tell which shader attributes are enabled / disabled.
Status 🚢
8. Put a bow on it
Add an isDisabled
function to the LayerType
attributes.
If this function returns false
the attribute will not be added to the buffer, disabled with disableVertexAttribArray
, and set by vertexAttrib*
.
If this function returns true
, calculate per-feature paint values using mapbox-gl-function
and feed them into the Buffer
.
depends on 1 - 6
Status 🚀
in pull request at #1932