Data-defined styles in Mapbox vector tiles

المشرف العام

Administrator
طاقم الإدارة
Is it possible to style Mapbox vector tiles (Mapbox GL JS) using a feature's attributes? Assuming each feature has an attribute color which is a hex color string, I tried

"paint": { "fill-color": function(d) { return d.color } }but received an error saying that a string was expected, not a function. Looking through some examples it seems that features of similar styles needed to be grouped into their own layers, but that seems a bit unwieldy in the event of a single layer with hundreds of possible styles.

What is the best way to style polygons based on a feature's attributes?



أكثر...
 
أعلى